Compiler Options

A handful of Compiler Options are available to customize how the compiler works. Most of these options can be set either globally via Project Settings and locally for a file or a sub-section of a file using special Compiler Directives.

Note: this page only covers the options that directly influence of the compiler and code generation. Many other settings are available that control other aspects of the whole build chain, many of them specific to certain platforms. Please refer to the Project Settings Reference for the complete list.

Allow Unsafe Code

Off by default, this setting enabled the use of "unsafe" Code such as Pointers on the .NET platform.

Check for Overflow/Underflow

Off by default, this setting enabled checks for integer under-flow and overflow. When set, integer operations that would exceed the range of values that can be held by the type will cause a runtime Exception.

Also available on a file-by-file basis via the following Compiler Directives:

  • {$Q+/-} or {$OVERFLOW ON/OFF/DEFAULT} (Oxygene)

Check Whitespace

Off by default, this setting enables the compiler to emit warnings when the indentation of begin/end or {/} pairs does not match. This can be helpful for maintaining well-formatted code, and can also help narrow down "mismatched begin/end or {/}" errors in complex code.

CrossPlatform

Also available on a file-by-file basis via the following Compiler Directives:

  • {$CROSSPLATFORM ON/OFF/DEFAULT} (Oxygene)
  • #pragma crossplatform on/off/default (C#, Swift and Java)

Emit Tail Calls

Off by default, this setting enables the compiler to emit optimize recursive calls via a technology called Tail Calls.

Also available on a file-by-file basis via the following Compiler Directives:

  • {$TAILCALLS ON/OFF/DEFAULT} – enables or disables compiler optimizations for Tail Calls

Enable Asserts

Off by default, this setting enables Assertions, via Class Contracts or the assert() System Function. When turned on, Asserts raise error and break execution flow. When off, Asserts and Class Contracts will no be compiled into the final code.

Enable Inlining

On by default, this setting enables the compiler to inline methods marked with as inline (Oxygene), __inline (C#) or @inline (Swift)

Optimize

On by default, this setting makes the compiler optimize code for size and performance, sacrificing debuggability and readability of the final binary.

Treat Fixable Errors as Warnings

Off by default (except ehen compiling from the IDE), this setting causes the compiler to "ignore" errors that hav a trivial fix (such as a misspelled identifier or a missing semicolon), and report them as warnings instead. If a project compiles without any other non-fixable errors, the compile will succeed as it would if the trivial fixes had been applied.

Note that this setting will not actually fix or touch the code (although the IDEs support an Auto-Fix feature for certain errors that can be turned on separately from this compiler option.

Treat Warnings as Errors

Off by default, this setting will instruct he compiler to fail compilation iof any warnings are encountered, even if there were no errors. This setting is helpful to enforce a "zero warnings" code policy.

Warn on Case Mismatch

Oxygene only: On by default, this setting will make the compiler emit warnings when the case of identifiers does not match between their declaration and their use. While Oxygene is not case sensitive, this option helps enforce consistent use of case through-out the code base.

Warn On Dynamic

Off by default, this setting causes the compiler to em it a warning when inadvertently calling members of a dynamic type. This can be helpful when converting code to be more strongly typed, especially on Cocoa, where the use of id is very common, but can lead to subtle unexpected side effects.

Warn On Implicit Not-Nullable Cast

Off by default, this setting instructs the compiler to emit a warning when potential null values are passed to values marked as expecting non-nill values only. See Nullability for more details.

Warn On Missing Exception Annotations

Off by default, this setting instructs the compiler to emit a warning when methods are missing Throws Definitions on the Java platform.

Non-Boolean Options

Conditional Defines

Sets a list of Conditional Defines that will be set for all files in the project. Individual defines will be separated by semicolons (;).

Default Uses

Can provide an optional list of Namespaces that will be implicitly in scope (i.e. used/imported) for each file in the project. Individual names can be separated by semicolons (;).

Root Namespace

The RootNamespace setting influences many parts of the build chain, as covered in the Project Settings section. For projects contains Swift or Go source files, it also controls the target namespace for code.

Since Swift source files do not specify a namespace at all, all classes (that don't specify a fully-qualified name containing dots) will be placed in the Root Namespace. For Go, all types will be places in appropriate sub-namespaces based on the project's folder hierarchy.

Legacy Options

Delphi Compatibility

Oxygene only: Off by default, this turns on Delphi Compatibility Mode. Also available on a file-by-file basis via the following Compiler Directives:

  • {$DELPHI ON/OFF/DEFAULT} Mode](/Oxygene/Delphi/DelphiCompatibilitySettings)
  • {$DELPHICOMPATIBILITY ON/OFF/DEFAULT}\

Delphi Divide

Oxygene only: Off by default, this turns on Delphi-compatible behavior for the / and div Operators. See Delphi Compatibility Mode for more details.

Allow Legacy ".Create"

Oxygene only: Off by default, this turns on Delphi-compatible Constructor Calls using the .Create syntax. See Delphi Compatibility Mode for more details.

Allow Legacy out Parameters

Oxygene only: Off by default, this turns on Delphi-compatible syntax for omitting var and out when passing such parameters to Method Calls. See Delphi Compatibility Mode for more details.

Allow Legacy with

Oxygene only: Off by default, this turns on Delphi-compatible unsafe with Statements. See Delphi Compatibility Mode for more details.

Use Legacy Preprocessor

Turns on the legacy Elements 9 and earlier macro preprocessor for {$IF and #if processing. This bypasses the more modern Conditional Compilation engine and disables certain advanced features such as using defined(). It is only recommended for legacy projects.

See Also