Delphi Compiler Switches

Delphi Compiler Switches 6,3/10 845 reviews

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)

Default Object Model

Island/Darwin only, this option controls the default object model used for classes and interfaces defined without explicit ancestor. The default is 'Island', and other valid values include 'Cocoa' and 'Swift'. See Object Models for more details.

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} (Oxygene)

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

Debugging DLL compiled with Delphi 7 in Delphi XE5
Dear Sirs/Madams, We are considering changing from Delphi 7 to Delphi XE5. Our project consists of a dll and an .exe file. I have begun converting the .exe file to Delphi XE5 and have successfully accessed the DLL compiled with Delphi 7. When I debug the DLL (using the 'run parameters' and changing 'host application' to the .exe file) in Delphi 7 I can set breakpoints etc. and they are triggered. However, when I attempt to debug the project in XE5, I get the following message: Module Load: xxx.dll. No Debug Info. Base Address: $015A0000. Process xxx.exe (2928) ...
Attempting to compile Delphi 5 code in Delphi XE5 is failing
Greetings All, If I'm not in the correct formum please tell me which one I should be in. Just upgraded to Delphi XE5 and am attempting to compile one of my Delphi 5 projects. I used Interbase Express I use either TDataSource -> TCDSProvider -> TDataSetProvider -> TIBQuery or TDataSource -> TClientDataSet -> TDataSetProvider -> TIBQuery Also used TIBDatabase, TIBTransaction, and TIBStoredProc I open the smallest project I have and click compile and almost immediately I receive this error Checking project dependencies... Compiling CITranEngine.dproj...
Delphi 7 Compiler takes > 3 minutes to compile
Ok, I'm pulling my hair out. This is reminiscent of Visual C++. I am working on a new project that includes the JCL/JVCL. It also uses a number of graphic images for buttons and backgrounds. If I change a single unit by adding a space before a line, save it, and compile I am looking at between a 3:00 and 4:20 minutes delay before the project is linked. I am running VMWare fusion 3.1 on a MacBook Pro Core 2 Duo 2.5 Ghz with 4Gb RAM. Initially I thought it had something to do with VMWare, but other projects compile in a snap. I have also experienced long pauses in th...
to compile or not to compile ?
Hi I've been dabbling with .net but am now trying to bite the bullet and learn it moving from classic asp I am a bit confused as to wether it is 'standard' practise to 'build' your project into dll's and upload these to the server or wether to simply use script and upload as you would classic asp to the server. what is 'standard' practise is there an advantage or disadvantage to using script / compiling thanks What is 'Standard' depends a bit upon the tool you are using. For VS.NET 2003, compiling into a dll placed in the bin folder is the default behavior. Othe...
Delphi XE5
Hi :-) Installed Delphi XE5 (RAD Studio Enterprise) and used it for a while. Then I changed the installation and added the mobile parts to do mobile Application Development. Installation gave no errors and I can start the Android emulator and I see my mobile phone Connects fine and becomes an available target. When starting a New blank (or any other) mobile Project I can not compile. Get the same error every time. Even when doing nothing at all before compiling. [DCC Fatal Error] Project1.dpr(1): F1027 Unit not found: 'System.pas' or binary equivalents (.dcu/.o) Cannot ...
What generals generally do
Reading a McChrystal thread elsewhere, I came across someone quoting a US general http://en.wikipedia.org/wiki/Smedley_Butler > I spent 33 years and four months in active military service and > during that period I spent most of my time as a high class thug for > Big Business, for Wall Street and the bankers. In short, I was a > racketeer, a gangster for capitalism. I helped make Mexico and > especially Tampico safe for American oil interests in 1914. I helped > make Haiti and Cuba a decent place for the National City Bank boys to > collect revenues in. I ...
Delphi 7 versus Delphi 2010 compiler directive {$Q-}
Hi, Could it be correct that there's a bug in Delphi7 where the compiler directive {$Q-} and {$Q+} works completely the opposite? When trying to build an existing Delhi 7 project in Delphi 2010 i found this weird behaviour. In D7 {$Q-} set overflow cheking on and in Delphi 2010 off ????? Regards, Arno Brinkman ABVisie -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Firebird open source database with many powerful SQL features: http://www.firebirdsql.org http://www.firebirdsql.info General database developer support: http://www.databasedevelopmentforum.com Support list for ...
dll fails when compiled with delphi 2010, but works with delphi 7
I may be doing good if someone can just point me to the right forum I have not created a dll for some time and have not written one with 2010 before. The dll I am creating will be called as a cfx function by either a ColdFusion or BlueDragon webserver. I have written cfx DLLs in the past. The function declaration is below, it is the standard declaration from ColdFusion or Bluegradon documention on creating a CFX. procedure ProcessTagRequest(Request: TCFXRequest); export; cdecl; Since this was the first time using 2010 I wrote a very basic function to build off that was not much mor...
delphi.general
Sorry if this is 'out of topic'! but since some days ago I can't read the group *embarcadero.public.delphi.language.delphi.general* Does anybody know if there's something wrong with it? Or maybe is my reader? (Thunderbird) I get this messagge when I try to read the latest messages: Error! newsgroup server responded:no such article found Perhaps the article has expired <692702@forums.embarcadero.com> (33145) Click here to remove all expired articles sergio wrote: > Sorry if this is 'out of topic'! but since some days ago I can'...
Delphi 2010: AV when switching from Default to debug layout and when closing Delphi
Hello, I experience strange AVs in rtl140.bpl when switching from the Default to the Debug Layout (e.g. when starting the application) or when closing Delphi 2010. I have a bunch of Addins (Modelmaker Code Explorer, EurekaLog, DDevExtensions, JCL, etc...), components installed. Any ideas/tools to possibly track down where the culprit is? Possibly simply an addin in combination with docked windows etc. Thanks, Thomas > {quote:title=Thomas Steinmaurer wrote:}{quote} > I experience strange AVs in rtl140.bpl when switching from the Default > to the Debug Layout (...
Is it posible to configure Delphi XE3 IDE to use Delphi 7 compiler/debuger
Hi! Like many other developer out there I have several project which has been developed with older version of Delphi (Delphi 7). Since theese projects rely on some components which are not compatible with newer versions of Delphi (no newer versions available) I'm forced to do any maintnance on theese projects using Delphi 7. Another solution would be to find replacment components which would provide me with same capabilities and work with latest versions of Delphi. But this would probbably require compleete rewritings of my projects (lots and lots of work). So currently I'm using...
Best practice when code should still compile with elder versions of Delphi but also Delphi 2009
When tryung to compile Turbopower Orpheus and other Turbopower products which I still use in my applications and therefor need to convert to Delphi 2009, I get lots of warnings even though others has made it possible to get Orpheus compiled. The problem is checking a char in a set which gives a type cast warning and suggests using a new function instead. [DCC Warning] ovcdbnum.pas(401): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit. So what would be the best practice here eg. correcting this ro...
C# compiling with Delphi
Hello, There has been a lot of talk of Compiling Delphi Pascal code to the .NET. I would like to be able to add C# code to Delphi (Win32) projects. That would be cool. Of course it would have limitations, but anyays, ability to cross use Object Pascal and C# would help a lot (Any direction). -TP- Tommi Prami wrote: > Hello, > > There has been a lot of talk of Compiling Delphi Pascal code to the .NET. > > I would like to be able to add C# code to Delphi (Win32) projects. That > would be cool. Of course it would have limitations, but anyays, ability &g...
Delphi Compiler BUG
test program: {$APPTYPE CONSOLE} program testbug; type TArray1 = array of char; TArray2 = array[0..2] of char; var a: TArray1; b: TArray2; c: array of char; procedure Check1(const A: TArray1); begin A[0] := '1'; // compiling passed, BUG1 end; procedure Check2(const A: TArray2); begin A[0] := '1'; // 'Error: E2064 Left side cannot be assigned to', OK end; procedure Check3(const A: array of char); begin A[0] := '1'; // 'Error: E2064 Left side cannot be assigned to', OK end; { main } begin Set...