======== Declares ========
++++++++++++ Introduction ++++++++++++
In this chapter we collect some general information needed to declare and call external functions.
To call a function in a shared library from within REALbasic, you must first declare it. A declare statement specifies the name of the function, the library in which it is to be found, and its parameters and return type. The first part of this chapter discusses the syntax of declare statements, including a discussion of parameter types peculiar to declares.
The interface to a shared library is usually given in the form of C header files. Thus to declare a function in REALbasic, you must translate the C prototype into a REALbasic declaration. This requires some understanding of the C language, and of how C programs are structured. I provide just enough discussion of C to make it possible for you to do the translation.
The various platforms supported by REALbasic use different executable formats, calling conventions, and processors. and Apple's announcement of the switch to Intel processors will almost certaily complicate the situation. We consider platform-specific issues, including various tricks and lore.
REALbasic 2005 adds a significant new feature, so-called soft declares. Functions that are soft-declared (declared softly, softly declared?) are loaded at runtime when first called, instead of at application startup. This is an extremely useful addition to the language; to name just one benefit, Windows developers can now declare both ASCII and wide variants of functions and switch between them at runtime, instead of having to do separate compiles. I discuss soft declares, including the supporting functions and classes, and a quirk or two.
.. toctree:: :maxdepth: 1
sharedlibraries memoryblock declarestatements ctorb platformspecific