next up previous contents
Next: Using conditionalsMessages and Up: Compiler directives Previous: Local directives

Global directives

  Global directives affect the whole of the compilation process. That is why they also have a command - line counterpart. The command-line counterpart is given for each of the directives.

$A : Align Data

This switch is recognized for Turbo Pascal Compatibility, but is not yet implemented. The alignment of data will be different in any case, since Free Pascal is a 32-bit compiler.

$B : Complete boolean evaluation

This switch is understood by the Free Pascal compiler, but is ignored. The compiler always uses shortcut evaluation, i.e. the evaluation of a boolean expression is stopped once the result of the total exression is known with certainty.

So, in the following example, the function Bofu, which has a boolean result, will never get called.

If False and Bofu then
  ...

$D : Debugging symbols

When this switch is on, the compiler inserts GNU debugging information in the executable. The effect of this switch is the same as the command-line switch -g. By default, insertion of debugging information is off.

$E : Emulation of coprocessor

This directive controls the emulation of the coprocessor. On the i386 processor, it is supported for compatibility with Turbo Pascal. The compiler itself doesn't do the emulation of the coprocessor. Under DOS, the DOS extender does this, and under LINUX, the kernel takes care of the coprocessor support.

If you use the Motorola 680x0 version, then the switch is recognized, as there is no extender to emulate the coprocessor, so the compiler must do that by itself.

There is no command-line counterpart for this directive.

$G : Generate 80286 code

This option is recognised for Turbo Pascal cmpatibility, but is ignored, because the compiler needs at least a 386 or higher class processor.

$L : Local symbol information

This switch (not to be confused with the {$L file} file linking directive) is recognised for Turbo Pascal compatibility, but is ignored. generation of symbol information is controlled by the $D switch.

$N : Numeric processing

This switch is recognised for Turbo Pascal compatibility, but is otherwise ignored, since the compiler always uses the coprocessor for floating point mathematics.

$O : Overlay code generation

This switch is recognised for Turbo Pascal compatibility, but is otherwise ignored, since the compiler requires a 386 or higher computer, with at least 4 Mb. of ram.

$Q : Overflow checking

The {$Q+} directive turns on integer overflow checking. This means that the compiler inserts code to check for overflow when doing computations with an integer. When an overflow occurs, the run-time library will print a message Overflow at xxx, and exit the program with exit code 1.

Using the {$Q-} switch switches off the overflow checking code generation.

The generation of overflow checking code can also be controlled using the -Co command line compiler option (see Users' guide\).

$R : Range checking

By default, the computer doesn't generate code to check the ranges of array indices, enumeration types, subrange types, etc. Specifying the {$R+} switch tells the computer to generate code to check these indices. If, at run-time, an index or enumeration type is specified that is out of the declared range of the compiler, then a run-time error is generated, and the program exits with exit code 1.

The {$R-} switch tells the compiler not to generate range checking code. This may result in faulty program behaviour, but no run-time errors will be generated.

Remark: this has not been implemented completely yet.

$S : Stack checking

The {$S+} directive tells the compiler to generate stack checking code. This generates code to check if a stack overflow occurred, i.e. to see whether the stack has grown beyond its maximally allowed size. If the stack grows beyond the maximum size, then a run-time error is generated, and the program will exit with exit code 1.

Specifying {$S-} will turn generation of stack-checking code off.

There is no command-line switch which is equivalent to this directive.

Remark: In principle, the stack is almost unlimited, i.e. limited to the total free amount of memory on the computer.

$X : Extended syntax

Extended syntax allows you to drop the result of a function. This means that you can use a function call as if it were a procedure. Standard this feature is on. You can switch it off using the {$X-} directive.

The following, for instance, will not compile :

function Func (var Arg : sometype) : longint;
begin
...          { declaration of Func }
end;

...

{$X-}
Func (A);
The reason this construct is supported is that you may wish to call a function for certain side-effects it has, but you don't need the function result. In this case you don't need to assign the function result, saving you an extra variable.

The command-line compiler switch -Sa1 has the same effect as the {$X+} directive.


next up previous contents
Next: Using conditionalsMessages and Up: Compiler directives Previous: Local directives

Michael Van Canneyt
Tue Mar 31 16:50:06 CEST 1998