As of FPC 2.3.1, the {$MODESWITCH} directive can be used to select some of the features that a {$MODE } directive would select.
It can be used to enable language features that would otherwise not be available in the current mode. For example, you might be programming in TP mode, but want to use the Out parameters, which are only available in Delphi mode.
The {$MODESWITCH } directive enables or disables individual mode features without 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:
Allow the use of advanced records (i.e. records with methods).
Allow inline procedures.
Allow use of ansistrings.
Automatic (silent) dereferencing of typed pointers.
C style blocks.
Use classical procedural variables.
Use object pascal classes.
Allow the use of the CVAR keyword.
Allow use of default parameter values.
Allow local variables in class methods to have the same names as properties of the class.
Allow the use of exceptions.
Support the hint directives (deprecated, platform etc.)
Allow use of Initialization and Finalization
Input/output as required by ISO pascal.
Mod operation as required by ISO pascal.
Program parameters as required by ISO pascal.
Unary minus as required by ISO pascal.
Use mac-style procedural variables.
Allow use of nested comments.
Allow assigning local procedures to procedural variables.
Allow jumping to a location outside the current scope.
Allow interfacing with Objective C version 1.
Allow interfacing with Objective C version 21.
Automatically include the ObjPas unit.
Allow use of the out parameter type.
Allow automatic conversion of null-terminated strings to strings,
Allow silent conversion of pointers to procedural variables.
Allow use of properties.
Implementation and Forward declaration must match completely.
Enable the Result identifier for function results.
Set the codepage to the code page of the platform on which the compiler is running. This is automatically enabled if you selected delphiunicode mode: {$mode delphiunicode}.
Allow the use of type helpers.
String is by default unicode string.
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+}