1.1 Introduction

Free Pascal supports compiler directives in the source file: Basically the same directives as in Turbo Pascal, Delphi and Mac OS pascal compilers. Some are recognized for compatibility only, and have no effect.

A compiler directive is always specified as a comment using curly braces:

{$DIRECTIVE [value]}

The older (* *) notation, or the C++ notation // cannot be used for directives.

The fact that a directive is specified as a comment means that it is not a pascal instruction. That in turn means that if a non-existing directive is specified, the compiler does not give an error, it just gives a warning about an invalid/unknown directive.

There is a distinction between local and global directives:

Some directives can only take a boolean value, which means a ’+’ to switch them on, or a ’-’ to switch them off. No space should be present between the boolean switch and the + or - sign. These directives are also known as switches. Many switches have a long form also. If they do, then the name of the long form is given also.

For long switches, the + or - character to switch the option on or off, may be replaced by the ON or OFF keywords. In that case, there must be a space between the directive name and the ON/OFF.

Thus {$I+} is equivalent to {$IOCHECKS ON} or {$IOCHECKS+} and {$C-} is equivalent to {$ASSERTIONS OFF} or {$ASSERTIONS-}

Note that anything after the ON/OFF or +/- or a value required by the directive, is ignored. i.e. the compiler parses the directive as far as it needs to in order to evaluate it, but the rest is skipped.

This means that in the following, everything after ’off’ is ignored:

{$warn 5023 off : no warning about unused units}

The long forms of the switches are the same as their Delphi counterparts.

It is worth mentioning that when defaults are indicated, this means defaults in the absence of a configuration file. The configuration files distributed with FPC will change some of the defaults mentioned here.