1.2.17 $MODESWITCH : Select mode features

As of FPC 2.3.1, the {$MODESWITCH} directive selects some of the features that a {$MODE } directive selects: it can be used to use features that would otherwise not be available in the current mode. For instance, one wishes to program in TP mode, but would like to use the ’Out’ parameter, an option available only in Delphi mode. The {$MODESWITCH } directive allows to activate or deactivate some individual mode features, while not changing the current compiler mode.

This switch is a global switch, and can be used wherever the {$MODE} switch can be used.

The syntax is as follows:

{$MODESWITCH XXX}  
{$MODESWITCH XXX+}  
{$MODESWITCH XXX-}

The first two will switch on feature XXX, the last one will switch it off.

The feature XXX can be one of the following:

CLASS
Use object pascal classes.
OBJPAS
Automatically include the ObjPas unit.
RESULT
Enable the Result identifier for function results.
PCHARTOSTRING
Allow automatic conversion of null-terminated strings to strings,
CVAR
Allow the use of the CVAR keyword.
NESTEDCOMMENTS
Allow use of nested comments.
CLASSICPROCVARS
Use classical procedural variables.
MACPROCVARS
Use mac-style procedural variables.
REPEATFORWARD
Implementation and Forward declaration must match completely.
POINTERTOPROCVAR
Allow silent conversion of pointers to procedural variables.
AUTODEREF
Automatic (silent) dereferencing of typed pointers.
INITFINAL
Allow use of Initialization and Finalization
POINTERARITHMETICS
Allow use of pointer arithmetic.
ANSISTRINGS
Allow use of ansistrings.
OUT
Allow use of the out parameter type.
DEFAULTPARAMETERS
Allow use of default parameter values.
HINTDIRECTIVE
Support the hint directives (deprecated, platform etc.)
DUPLICATELOCALS
Allow local variables in class methods to have the same names as properties of the class.
PROPERTIES
Allow use of global properties.
ALLOWINLINE
Allow inline procedures.
EXCEPTIONS
Allow the use of exceptions.

Hence, the following:

{$MODE TP}  
{$MODESWITCH OUT}

Will switch on the support for the out parameter type in TP mode. It is equivalent to

{$MODE TP}  
{$MODESWITCH OUT+}