Compiler directives are compiler options embedded in the sourcecode. This allows you to change the state of a compiler option for a limited rangeof source code lines. The syntax of a given compiler directive can be found by accessingthe context sensitive help in the compiler options dialog or by viewing the CompilerOptions help. You can shorten the name entered for a compiler directive to the minimumunique number of characters needed to identify the directive from all other directives.For example, /OPTIMIZE can be shorted to /OPT.
Modula-2 compiler directives take the form of
Ada95 directives take the form of
Each compiler directive has a defined scope of action. See Compilerdirective scopes.
The following are additional compiler directives not availableon the compiler options dialog.
/PUSH and /POP
These directives go together. You use them to save and restorethe compiler option state around code where you are altering one or more compileroptions. An example is the best illustration.
Hash := Hash + Hash + ORD(String[i]);
Hash := Hash + Hash + Natural(String[i]);
In this example the embedded directive is turning overflow checkingoff for a specific line of code. The state of the overflow checking option is preservedfor all other lines of code in the source file.
You may nest /PUSH directives up to 16 levels deep before thecompiler internal option stack overflows and generates a compilation error.
This directive causes the compiler to generate code for the mainprogram as the entry point for a DLL/Shared object. The DLL entry point is calledwhen a program attaches to the DLL. For termination code you can have a FINALLY sectionin the main program. The module initialization is called when the DLL is attachedand the termination code is called when the DLL is unloaded.
The optional thread option is only available for Win32 and itmeans the DLL entry and termination code will be called once for each thread thatattaches to the DLL.
This directive causes all procedures declared after this directiveto have the EXPORT procedure attribute.
This directive causes all procedures declared after this directiveto have the PROPAGATEEXCEPTION procedure attribute.
This procedure attribute is generally used in with the EXPORTALLand PROPAGATEEXCEPTIONALL directives. This directive is used in a Modula-2 definitionmodule, or a Ada95 package specification module, and informs each procedure declaredafter this directive to use the procedure attributes declared in this module on theprocedure implementations in the Modula-2 implementation module, or Ada95 Packagebody. This saves you from re-entering the procedure attributes on each procedureagain on the implementation. This makes it easy to export a number of proceduresfrom a DLL.
This directive allows you to change the default calling conventionof the compiler. The calling convention is changed for all procedure s declared afterthis directive.
/CALLS:[StonyBrook | SBOSSystem | Cdecl | msCdecl | Cpascal |OSCall | OS2System | WatcomS | StdCall |Win32System | WinSystem | Linux | SunOS ]
See Procedure Attributes for informationof the various calling conventions.
The compiler ignores this directive. This directive is used bythe environment to create a dependency between a source file and a resource file.This allows the environment to automatically add resources to programs by using thisdirective. This directive must be in the imports section of the source file sincethis directive is treated as a kind of import.
where: resourceName is the name of the source file. Do not include any path information in resourceName.
The RES environment directory option is used to find these files.
The compiler ignores this directive. This directive is used bythe environment to create a dependency between a source file and a an object libraryor shared object. This allows the environment to automatically add these files toprogram linking by using this directive. This directive must be in the imports sectionof the source file since this directive is treated as a kind of import.
where: libraryName is the name of the source file. Do not include any path information in libraryName, but include the file extension. The extension is used to identify the type of file.
.lib => object library
.a => object library
.so => shared object
The LIB/SO environment directory option is used find the thesefiles.
System standard directories are also searched. System standardlibrary directories are used mostly on Unix systems. Each system defines its ownmechanism for what the standard directories are. On Win32 the LIB environment variableis considered a "standard" directory search path to find library files.The LIB/SO directories are searched before the system dependent directories.
If a source file has more than one LIBNEEDED directive then thelibraries will be linked in the order of directives in the source file.
This directive specifies that all procedures after this directivewill not accept array bound information for unconstrained array parameter types.This is primarily useful for interfacing with the operating system and other languagessuch as C.
Examples of unconstrained array parameter types.
PROCEDURE Example(str : ARRAY OF CHAR);
PROCEDURE Example(str : String);
The Version tags option allows the user to specify version tagsfor the conditional compilation system.
This option allows you to remove a version tag from the definedlist of version tags.
The Valid version tags option allows the user to specify validversion tags for the conditional compilation system.
/ENUMSIZE:[Small | Big]
The enumsize option allows you to modify the size of enumerationtypes with less than 257 elements. A value of Small means than the enumeration typewill be one byte in size. Big means the enumeration type will be the size of INTEGER.
Generally you should let the compiler use the default size forenumeration types. However this option can be useful when interfacing with C code.You can also change the size of individual enumeration types using the Small andBig keywords in the declaration. See the language reference for more information.
/SETSIZE:[Small | Big]
The setsize option allows you to modify the size of set typeswith less than 33 elements. A value of Small means than the set type will be oneor two bytes in size. A set with less than 9 elements will be one byte. A set withless than 17 elements will be two bytes. Big means the set type will be the sizeof INTEGER.
Generally you should let the compiler use the default size forset types. However this option can be useful when interfacing with C code. You canalso change the size of individual set types using the Small and Big keywords inthe declaration. See the language reference for more information.
This option is only valid in a main program file and it directsthe compiler to make the main program entry point appear to be a "typical"C program entry point.
This option is only used when the CMAIN directive is used, andit sets the public symbol name of the main program entry point.