Compiler directives
This appendix describes the compiler directives you can use to control the features of the Delphi compiler. They are listed alphabetically. Each compiler directive is classified as either a switch, parameter, or conditional compilation directive.
Following the list of compiler directives is a brief discussion of how to use the conditional compilation directives. This reference section describes how to use conditional constructs and symbols to produce different code from the same source text.
A compiler directive is a comment with a special syntax. Delphi allows compiler directives wherever comments are allowed. A compiler directive starts with a $ as the first character after the opening comment delimiter, immediately followed by a name (one or more letters) that designates the particular directive. You can include comments after the directive and any necessary parameters.
Three types of directives are described in this appendix:
- Switch directives turn particular compiler features on or off by
specifying + or -
immediately after the directive name. Switch directives are either global or local.
Global directives affect the entire compilation and must appear before the declaration part of the program or the unit being compiled.
Local directives affect only the part of the compilation that extends from the directive until the next occurrence of the same directive. They can appear anywhere.
Switch directives can be grouped in a single compiler directive comment by separating them with commas with no intervening spaces. For example,
{$B+,R-,S-}
-
Parameter directives. These directives specify parameters that
affect the compilation, such as file names and memory sizes.
-
Conditional directives. These directives control conditional
compilation of parts of the source text, based on user-definable conditional symbols. See page 242 for information about using conditional directives.
All directives, except switch directives, must have at least one blank between the directive name and the parameters. Here are some examples of compiler directives:
{$B+}
{$R- Turn off range checking}
{$I TYPES.INC}
{$M 32768,4096}
{$DEFINE Debug}
{$IFDEF Debug}
{$ENDIF}
You can insert compiler directives directly into your source code. You can also change the default directives for both the command-line compiler (DCC.EXE) and the IDE (DELPHI.EXE). The Options|Project|Compiler dialog box contains many of the compiler directives; any changes you make to the settings there will affect all subsequent compilations.
When using the command-line compiler, you can specify compiler directives on the command line (for example, DCC /$R+ MYPROG), or you can place directives in a configuration file (see page 222). Compiler directives in the source code always override the default values in both the command-line compiler and the IDE.
If you are working in the Delphi editor and want a quick way to see what compiler directives are in effect, press Ctrl+O O. Delphi will insert the current settings in the edit window at the top of your file.
Align data
Type Switch
Syntax {$A+} or {$A-}
Default {$A+}
Scope Global
Remarks
The $A directive switches between byte and word alignment of variables and typed constants. On all 80x86 CPUs, word alignment means faster execution because word-sized items on even addresses are accessed in one memory cycle rather than two memory cycles for words on odd addresses.
In the {$A+} state, all variables and typed constants larger than one byte are aligned on a machine-word boundary (an even-numbered address). If required, unused bytes are inserted between variables to achieve word alignment. The {$A+} directive does not affect byte-sized variables, nor does it affect fields of record structures and elements of arrays. A field in a record will align on a word boundary only if the
total size of all fields before it is even. For every element of an array to align on a word boundary, the size of the elements must be even.
In the {$A-} state, no alignment measures are taken. Variables and typed constants are simply placed at the next available address, regardless of their size.
Regardless of the state of the $A directive, each global var and const declaration section always starts at a word boundary. The compiler always keeps the stack pointer (SP) word aligned by allocating an extra unused byte in a procedure's stack frame if required.
Boolean evaluation
Type Switch
Syntax {$B+} or {$B-}
Default {$B-}
Scope Local
Remarks
The $B directive switches between the two different models of code generation for the and and or Boolean operators.
In the {$B+} state, the compiler generates code for complete Boolean expression evaluation. This means that every operand of a Boolean expression built from the and and or operators is guaranteed to be evaluated, even when the result of the entire expression is already known.
In the {$B-} state, the compiler generates code for short-circuit Boolean expression evaluation, which means that evaluation stops as soon as the result of the entire expression becomes evident.
For further details, see the section "Boolean operators" in Chapter 5, "Expressions."
Code segment attribute
Type Parameter
Syntax {$C attribute attribute ...}
Default {$C MOVEABLE DEMANDLOAD DISCARDABLE}
Scope Global
Remarks
The $C directive is used to control the attributes of a code segment. Every code segment in an application or library has a set of attributes that determine the behavior of the code segment when it is loaded into memory. For example, you can specify that a code segment is moveable, which means Windows can move the code
segment around in memory as needed, or you can specify that a code segment is
fixed, which means the location of the code segment in memory cannot change.
A $C directive affects only the code segment of the module (unit, program, or library) in which it is placed. For more information, see "Code Segments" in Chapter
16. In the following table, the code-segment attribute options occur in groups of two; each option has an opposite toggle. Here are the grouped options:
MOVEABLE The system can change location of code segment in linear memory.
FIXED The system can't change location of code segment in linear memory.
DEMANDLOAD Code segment loads only when it is needed.
PRELOAD Code segment loads when the program begins executing.
DISCARDABLE Code segment can be unloaded when it's no longer needed.
PERMANENT Code segment remains in memory once it is loaded.
The first option of each group is the default. You may specify multiple code segment attributes using the $C directive. If both options of a group in a $C directive are specified, only the last one will take effect. For example,
{$C FIXED MOVEABLE DISCARDABLE }
will make the code segment moveable, and it can be discarded when it is no longer needed.
Debug information
Type Switch
Syntax {$D+} or {$D-}
Default {$D+}
Scope Global
Remarks
The $D directive enables or disables the generation of debug information. This information consists of a line-number table for each procedure, which maps object- code addresses into source text line numbers.
For units, the debug information is recorded in the unit file along with the unit's object code. Debug information increases the size of unit file and takes up additional room when compiling programs that use the unit, but it does not affect the size or speed of the executable program.
When a program or unit is compiled in the {$D+} state, Delphi's integrated debugger lets you single-step and set breakpoints in that module.
The TDW Debug Info (Options|Project) and Map File (Options|Project) options produce complete line information for a given module only if you've compiled that module in the {$D+} state.
The $D switch is usually used in conjunction with the $L switch, which enables and disables the generation of local symbol information for debugging.
If you want to use Turbo Debugger to debug your program, choose Options|Project, and check the TDW Debug Info option.
DEFINE directive
Type Conditional compilation
Syntax {$DEFINE name}
Remarks
Defines a conditional symbol with the given name. The symbol is recognized for the remainder of the compilation of the current module in which the symbol is declared, or until it appears in an {$UNDEF name} directive. The {$DEFINE name} directive has no effect if name is already defined.
Description
Type Parameter
Syntax {$D text}
Scope Global
Remarks
The $D directive inserts the text you specify into the module description entry in the header of a .EXE or .DLL.Traditionally the text is a name and version number, but you may specify any text of your choosing. For example,
{$D My Application version 12.5}
ELSE directive
Type Conditional compilation
Syntax {$ELSE}
Remarks
Switches between compiling and ignoring the source text delimited by the last
{$IFxxx} and the next {$ENDIF}.
ENDIF directive
Type Conditional compilation
Syntax {$ENDIF}
Remarks
Ends the conditional compilation initiated by the last {$IFxxx} directive.
Extended syntax
Type Switch
Syntax {$X+} or {$X-}
Default {$X+}
Scope Global
Remarks
The $X directive enables or disables Delphi's extended syntax:
-
Function statements. In the {$X+} mode, function calls can be
used as procedure calls; that is, the result of a function call can be discarded. Generally, the computations performed by a function are represented through its result, so discarding the result makes little sense. However, in certain cases a function can carry out multiple operations based on its parameters and some of those cases might not produce a useful result. When that happens, the {$X+} extensions allow the function to be treated as a procedure.
-
Null-terminated strings. A {$X+} compiler directive enables
Delphi's support for null-terminated strings by activating the special rules that apply to the built-in PChar type and zero-based character arrays. For more details about null- terminated strings, see Chapter 15, "Using null-terminated strings."
Note The {$X+} directive does not apply to built-in functions (those defined in the System
unit).
Force Far calls
Type Switch
Syntax {$F+} or {$F-}
Default {$F-}
Scope Local
Remarks
The $F directive determines which call model to use for subsequently compiled procedures and functions. Procedures and functions compiled in the {$F+} state always use the far call model. In the {$F-} state, Delphi automatically selects the appropriate model: far if the procedure or function is declared in the interface section of a unit; otherwise it is near.
The near and far call models are described in full in Chapter 17, "Control issues."
Generate 80286 Code
Type Switch
Syntax {$G+} or {$G-}
Default {$G+}
Scope Global
Remarks
The $G directive enables or disables 80286 code generation. In the {$G-} state, only generic 8086 instructions are generated, and programs compiled in this state can run on any 80x86 family processor. You can specify {$G-} any place within your code.
In the {$G+} state, the compiler uses the additional instructions of the 80286 to improve code generation, but programs compiled in this state cannot run on 8088 and 8086 processors. Additional instructions used in the {$G+} state include ENTER, LEAVE, PUSH immediate, extended IMUL, and extended SHL and SHR.
Group unit segments
Type Parameter
Syntax {$G unitname unitname ...}
Scope Global
Remarks
The $G directive lets you specify groups of units you want the linker to place in the same segment. Grouping units in the same segment ensures that the units swap in and out of memory at the same time. The $G directive is primarily used to group units containing discardable code.
Each $G directive specifies a group of units. $G directives are valid only in a program or library, and must appear after the program or library's uses clause. The
compiler reports an error if you attempt to add a unit to more than one group. In addition to any groups created with $G, the compiler maintains a default group that includes all units not explicitly grouped.
Code segment attributes are controlled by the $C directive. The preferred segment size is set with $S.
The linker minimizes the number of code segments in an executable file by combining all units that belong to the same group. Two or more units are put into the same code segment if they belong to the same group and have the same code segment attributes, and if the combined size does not exceed the preferred segment size.
The linker will never put units that belong to different groups in the same code segment.
IFDEF directive
Type Conditional compilation
Syntax {$IFDEF name}
Remarks
Compiles the source text that follows it if name is defined.
IFNDEF directive
Type Conditional compilation
Syntax {$IFNDEF name}
Remarks
Compiles the source text that follows it if name is not defined.
IFOPT directive
Type Conditional compilation
Syntax {$IFOPT switch}
Remarks
Compiles the source text that follows it if switch is currently in the specified state. switch consists of the name of a switch option, followed by a + or a - symbol. For example, the construct
{$IFOPT N+}
type Real = Extended;
{$ENDIF}
will compile the type declaration if the $N option is currently active.
Include file
Type Parameter
Syntax {$I filename}
Scope Local
Remarks
The $I parameter directive instructs the compiler to include the named file in the compilation. In effect, the file is inserted in the compiled text right after the {$I filename} directive. The default extension for filename is .PAS. If filename does not specify a directory path, then, in addition to searching for the file in the same directory as the current module, Delphi searches in the directories specified in the Search path input box on the Directories/Conditionals page of the Options|Project dialog (or in the directories specified in a /I option on the DCC command line).
There is one restriction to the use of include files: An include file can't be specified in the middle of a statement part. In fact, all statements between the begin and end of a statement part must exist in the same source file.
Input/output checking
Type Switch
Syntax {$I+} or {$I-}
Default {$I+}
Scope Local
Remarks
The $I switch directive enables or disables the automatic code generation that checks the result of a call to an I/O procedure. I/O procedures are described in Chapter 13, "Input and output." If an I/O procedure returns a nonzero I/O result when this switch is on, an EInOutError exception is raised (or the program is terminated if exception handling is not enabled). When this switch is off, you must check for I/O errors by calling IOResult.
Link object file
Type Parameter
Syntax {$L filename}
Scope Local
Remarks
The $L parameter instructs the compiler to link the named file with the program or unit being compiled. The $L directive is used to link with code written in for subprograms declared to be external. The named file must be an Intel relocatable object file (.OBJ file). The default extension for filename is .OBJ. If filename does not specify a directory path, then, in addition to searching for the file in the same directory as the current module, Delphi searches in the directories specified in the Search path input box on the Directories/Conditionals page of the Options|Project dialog (or in the directories specified in a /O option on the DCC command line). For further details about linking with assembly language, see Chapter 20, "Linking assembler code."
Local symbol information
Type Switch
Syntax {$L+} or {$L-}
Default {$L+}
Scope Global
Remarks
The $L switch directive enables or disables the generation of local symbol information. Local symbol information consists of the names and types of all local variables and constants in a module, that is, the symbols in the module's implementation part and the symbols within the module's procedures and functions.
For units, the local symbol information is recorded in the unit file along with the unit's object code. Local symbol information increases the size of unit files and takes up additional room when compiling programs that use the unit, but it does not affect the size or speed of the executable program.
When a program or unit is compiled in the {$L+} state, Delphi's integrated debugger lets you examine and modify the module's local variables. Furthermore, calls to the module's procedures and functions can be examined via the View|Call Stack.
The Include TDW debug info and Map file options on the Linker page of the Options|Project dialog produce local symbol information for a given module only if that module was compiled in the {$L+} state.
The $L switch is usually used in conjunction with the $D switch, which enables and disables the generation of line-number tables for debugging. The $L directive is ignored if the compiler is in the {$D-} state.
Memory allocation sizes
Type Parameter
Syntax {$M stacksize,heapsize}
Default {$M 16384,8192}
Scope Global
Remarks
The $M directive specifies an application or library's memory allocation parameters. stacksize must be an integer number in the range 1,024 to 65,520 which specifies the size of the stack segment. Heapsize specifies the size of the local heap area in the data segment. heapsize must be an integer number in the range 0 to 65520.
The $M directive has no effect when used in a unit. Furthermore, the stacksize parameter in a $M directive is ignored in a library (a library always uses the stack of the applications that call it).
Numeric coprocessor
Type Switch
Syntax {$N+} or {$N-}
Default {$N+}
Scope Global
Remarks
The $N directive switches between the two different models of floating-point code generation supported by Delphi. In the {$N-} state, code is generated to perform all real-type calculations in software by calling run-time library routines. In the {$N+} state, code is generated to perform all real-type calculations using the 80x87 numeric coprocessor.
Open String Parameters
Type Switch
Syntax {$P+} or {$P-}
Default {$P+}
Scope Local
Remarks
The $P directive controls the meaning of variable parameters declared using the string keyword. In the {$P-} state, variable parameters declared using the string keyword are normal variable parameters, but in the {$P+} state, they are open string parameters. Regardless of the setting of the $P directive, the OpenString identifier can always be used to declare open string parameters. For more information about open parameters, see Chapter 8, "Procedures and functions."
Overflow checking
Type Switch
Syntax {$Q+} or {$Q-}
Default {$Q-}
Scope Local
Remarks
The $Q directive controls the generation of overflow checking code. In the {$Q+} state, certain integer arithmetic operations (+, -, *, Abs, Sqr, Succ, and Pred) are checked for overflow. The code for each of these integer arithmetic operations is followed by additional code that verifies that the result is within the supported range. If an overflow check fails, an EIntOverflow exception is raised (or the program is terminated if exception handling is not enabled).
The {$Q+} does not affect the Inc and Dec standard procedures. These procedures are never checked for overflow.
The $Q switch is usually used in conjunction with the $R switch, which enables and disables the generation of range-checking code. Enabling overflow checking slows down your program and makes it somewhat larger, so use {$Q+} only for debugging.
Pentium safe FDIV operations
Type: Switch
Syntax: {$U+} or {$U-}
Default: {$U+}
Scope: Local
The $U directive controls generation of floating-point code that guards against the flawed FDIV instruction exhibited by certain early Pentium processors.
In the {$U+} state, all floating-point divisions are performed using a run-time library routine. The first time the floating-point division routine is invoked, it checks whether the processor's FDIV instruction works correctly, and updates the TestFDIV
variable (declared in the System unit) accordingly. For subsequent floating-point divide operations, the value stored in TestFDIV is used to determine what action to take.
Table B-1 TestFDIV values
-1 FDIV instruction has been tested and found to be flawed.
-
FDIV instruction has not yet been tested.
-
FDIV instruction has been tested and found to be correct.
For processors that do not exhibit the FDIV flaw, {$U+} results in only a slight performance degredation. For a flawed Pentium processor, floating-point divide operations may take up to three times longer in the {$U+} state, but they will always produce correct results.
In the {$U-} state, floating-point divide operations are performed using in-line FDIV instructions. This results in optimum speed and code size, but may produce incorrect results on flawed Pentium processors. You should use the {$U-} state only in cases where you are certain that the code is not running on a flawed Pentium processor.
Range checking
Type Switch
Syntax {$R+} or {$R-}
Default {$R-}
Scope Local
Remarks
The $R directive enables or disables the generation of range-checking code. In the
{$R+} state, all array and string-indexing expressions are verified as being within the defined bounds, and all assignments to scalar and subrange variables are checked to be within range. If a range check fails, an ERangeError exception is raised (or the program is terminated if exception handling is not enabled).
Enabling range checking slows down your program and makes it somewhat larger, so use the {$R+} only for debugging.
Resource file
Type Parameter
Syntax {$R Filename}
Scope Local
Remarks
The $R directive specifies the name of a resource file to be included in an application or library. The named file must be a Windows resource file and the default extension for filename is .RES.
When a {$R filename} directive is used in a unit, the specified filename is simply recorded in the resulting unit file. No checks are made at that point to ensure that the filename is correct and that it specifies an existing file.
When an application or library is linked (after compiling the program or library source file), the resource files specified in all used units as well as in the program or library itself are processed and, each resource in each resource file is copied to the
.EXE or .DLL being produced. During the resource processing phase, Delphi's linker searches for .RES files in the same directory as the module containing the $R directive, and in the directories specified in the Search path input box on the Directories/Conditionals page of the Options|Project dialog (or in the directories specified in a /R option on the DCC command line).
Run-time type information
Type: Switch
Syntax: {$M+} or {$M-}
Default: {$M-}
Scope: Local
The $M switch directive controls generation of run-time type information. When a class is declared in the {$M+} state, or is derived from a class that was declared in the {$M+} state, the compiler generates run-time type information for fields, methods, and properties that are declared in a published section. If a class is declared in the {$M–} state, and is not derived from a class that was declared in the
{$M+} state, published sections are not allowed in the class.
Note The TPersistent class defined in the Classes unit of the Delphi Visual Class Library was declared in the {$M+} state, so any class derived from TPersistent is allowed to contain published sections. The Delphi Visual Class Library uses the run-time type information generated for published sections to access the values of a component's properties when saving a loading form files. Furthermore, the Delphi IDE uses a component's run-time type information to determine the list of properties to show in the Object Inspector.
There is seldom, if ever, any need for an application to directly use the $M compiler switch.
Segment size preference
Type Parameter
Syntax {$S segsize}
Default {$S 16384}
Scope Global
Remarks
The $S parameter directive is valid only in a main program or library. The directive specifies the preferred size of code segments for grouped units. The specified size must be in the range 0..65,535. Units that exceed the specified size are placed in their own code segments.
When grouping units, the linker puts units with the same code segment attributes into the same code segment, up to the size specified. The limit also applies to groups specified by the $G directive. Grouping of units is explained under the $G directive.
The $S directive never produces warnings or error messages. If a unit can't fit into a code segment with other units, it automatically is placed into a separate segment.
Setting the preferred segment size to 0 guarantees that every unit goes in a separate code segment; this was the default behavior in previous versions of the compiler.
Smart callbacks
Type Switch
Syntax {$K+} or {$K-}
Default {$K+}
Scope Global
Remarks
The $K directive controls the generation of smart callbacks for procedures and functions that are exported by an application. When an application is compiled in the {$K-} state, it must use the MakeProcInstance and FreeProcInstance Windows API routines when it creates callback routines. In the default {$K+} state, the application itself can call exported entry points, and there is no need to use MakeProcInstance and FreeProcInstance.
For more details about smart callbacks, see "Entry and exit code" in Chapter 17.
Stack-overflow checking
Type Switch
Syntax {$S+} or {$S-}
Default {$S+}
Scope Local
Remarks
The $S directive enables or disables the generation of stack-overflow checking code. In the {$S+} state, the compiler generates code at the beginning of each procedure or function that checks whether there is sufficient stack space for the local variables and other temporary storage. When there is not enough stack space, a call to a procedure or function compiled with {$S+} an EStackFault exception to be raised (or it causes the program to be terminated if exception handling is not enabled). In the
{$S-} state, such a call is likely to cause a system crash.
Symbol reference information
Type Switch
Syntax {$Y+} or {$Y-}
Default {$Y+}
Scope Global
Remarks
The $Y directive enables or disables generation of symbol reference information. This information consists of tables that provide the line numbers of all declarations of and references to symbols in a module.
For units, the symbol reference information is recorded in the .DCU file along with the unit's object code. Symbol reference information increases the size of the .DCU files, but it does not affect the size or speed of the executable program.
When a program or unit is compiled in the {$Y+} state, Delphi's integrated browser can display symbol definition and reference information for that module.
The $Y switch is usually used in conjunction with the $D and $L switches, which control generation of debug information and local symbol information. The $Y directive has no effect unless both $D and $L are enabled.
Type-checked pointers
Type Switch
Syntax {$T+} or {$T-}
Default {$T-}
Scope Global
Remarks
The $T directive controls the types of pointer values generated by the @ operator. In the {$T-} state, the result type of the @ operator is always an untyped pointer that is compatible with all other pointer types. When @ is applied to a variable reference in
the {$T+} state, the type of the result is ^T, where T is compatible only with other pointers to the type of the variable.
UNDEF directive
Type Conditional compilation
Syntax {$UNDEF name}
Remarks
Undefines a previously defined conditional symbol. The symbol is forgotten for the remainder of the compilation or until it reappears in a {$DEFINE name} directive. The {$UNDEF name} directive has no effect if name is already undefined.
Var-string checking
Type Switch
Syntax {$V+} or {$V-}
Default {$V+}
Scope Local
Remarks
The $V directive controls type checking on strings passed as variable parameters. In the {$V+} state, strict type checking is performed, requiring the formal and actual parameters to be of identical string types. In the {$V-} (relaxed) state, any string type variable is allowed as an actual parameter, even if the declared maximum length is not the same as that of the formal parameter.
The {$V-} state essentially provides an "unsafe" version of open string parameters. Although {$V-} is still supported, you should use open string parameters. For additional information, see "Open string parameters" in Chapter 8.
Windows stack frames
Type Switch
Syntax {$W+} or {$W-}
Default {$W-}
Scope Local
Remarks
The $W directive controls the generation of Windows-specific procedure entry and exit code for far procedures and functions. In the {$W+} state, special entry and exit code is generated for far procedures and functions. Some debugging tools require this special entry and exit code to correctly identify far call stack frames.
In the {$W-} state, no special entry and exit code is generated for far procedures and functions. This is the recommended state for final applications.
See Chapter 17 for additional information.
Word sized enumeration types
Type Switch
Syntax {$Z+} or {$Z-}
Default {$Z-}
Scope Local
Remarks
The $Z directive controls the storage size of enumerated types. An enumerated type declared in the the {$Z+} state is always stored as a word. An enumerated type declared in the {$Z–} state is stored as a byte if the type has no more than 256 values; otherwise it is stored as a word. The {$Z+} state is useful for interfacing with C and C++ libraries, which usually represent enumerated types as words.
Using conditional compilation directives
Two basic conditional compilation constructs closely resemble Pascal's if statement. The first construct
{$IFxxx} ƒ
{$ENDIF}
causes the source text between {$IFxxx} and {$ENDIF} to be compiled only if the condition specified in {$IFxxx} is True. If the condition is False, the source text between the two directives is ignored.
The second conditional compilation construct
{$IFxxx} ƒ
{$ELSE}
ƒ
{$ENDIF}
causes either the source text between {$IFxxx} and {$ELSE} or the source text between {$ELSE} and {$ENDIF} to be compiled, depending on the condition specified by the {$IFxxx}.
Here are some examples of conditional compilation constructs:
{$IFDEF Debug} Writeln('X = ', X);
{$ENDIF}
{$IFDEF CPU87}
{$N+}
type
Real = Double;
{$ELSE}
{$N-}
type
Single = Real;
Double = Real;
Extended = Real;
Comp = Real;
{$ENDIF}
You can nest conditional compilation constructs up to 16 levels deep. For every
{$IFxxx}, the corresponding {$ENDIF} must be found within the same source file-- which means there must be an equal number of {$IFxxx}'s and {$ENDIF}'s in every source file.
Conditional symbols
Conditional compilation is based on the evaluation of conditional symbols. Conditional symbols are defined and undefined using the directives
{$DEFINE name}
{$UNDEF name}
You can also use the /D switch in the command-line compiler to define a symbol (or add the symbol to the Conditional Defines input box on the Directories/Conditionals page of the Options|Project dialog box in the IDE).
Conditional symbols are best compared to Boolean variables: They are either True (defined) or False (undefined). The {$DEFINE} directive sets a given symbol to True, and the {$UNDEF} directive sets it to False.
Conditional symbols follow the same rules as Pascal identifiers: They must start with a letter, followed by any combination of letters, digits, and underscores. They can be of any length, but only the first 63 characters are significant.
Conditional symbols and Pascal identifiers have no correlation whatsoever. Conditional symbols cannot be referenced in the actual program and the program's identifiers cannot be referenced in conditional directives. For example, the construct
const
Debug = True;
begin
{$IFDEF Debug} Writeln('Debug is on');
{$ENDIF}
end;
will not compile the Writeln statement. Likewise, the construct
{$DEFINE Debug}
begin
if Debug then
Writeln('Debug is on');
end;
will result in an unknown identifier error in the if statement. Delphi defines the following standard conditional symbols:
VER80 Always defined, indicating that this is version 8.0 of Delphi. Each version has corresponding predefined symbols; for example, version 9.0 would have VER90 defined, version 9.5 would have VER95 defined, and so on.
WINDOWS Indicates that the operating environment is MS-Windows.
CPU86 Always defined, indicating that the CPU belongs to the 80x86 family of processors. Versions of Delphi for other CPUs will instead define a symbolic name for that particular CPU.
CPU87 Defined if an 80x87 numeric coprocessor is present at compile time.
Other conditional symbols can be defined before a compilation by using the Conditional Defines input box, or the /D command-line option if you are using the command-line compiler.
A p p e n d i x