RAD Studio (Common)
ContentsIndex
PreviousUpNext
Compiler

ProjectOptionsCompiler 

Use this page to set the compiler options for the current project.

Note: Not all of the options described below are available for all types of projects.

Code generation items 
Description 
Build Configuration 
Displays the current named build configuration associated with the options on this page. There are two default build configurations: Debug and Release. To create additional build configurations, enter a name in this field and click Save As. To delete the named build configuration displayed in this field, click Delete.  
Optimization 
Controls code optimization. When enabled (equivalent to {$O+}), the compiler performs a number of code optimizations, such as placing variables in CPU registers, eliminating common subexpressions, and generating induction variables. When disabled, (equivalent to {$O-}), all such optimizations are disabled. Other than for certain debugging situations, you should never have a need to turn optimizations off. All optimizations performed by the Delphi compiler are guaranteed not to alter the meaning of a program. In other words, the compiler performs no "unsafe" optimizations that require special awareness by the programmer.
This option can only turn optimization on or off for an entire procedure or function. You can't turn optimization on or off for a single line or group of lines within a routine.  
Stack frames 
Delphi for Win32 only. Controls the generation of stack frames for procedures and functions. When enabled, (equivalent to {$W+}), stack frames are always generated for procedures and functions, even when they're not needed. When disabled, (equivalent to {$W-}), stack frames are only generated when they're required, as determined by the routine's use of local variables. Some debugging tools require stack frames to be generated for all procedures and functions, but other than that you should never have a need to enable this option.  
Pentium-save FDIV 
Delphi for Win32 only. Controls generation of floating-point code that guards against the flawed FDIV instruction exhibited by certain early Pentium processors. Windows 95, Windows NT 3.51, and later Windows OS versions contain code that corrects the Pentium FDIV bug system-wide. When enabled (equivalent to {$U+}), all floating-point divisions are performed using a runtime library routine. The first time the floating-point division routine is invoked, it checks whether the processor's FDIV instruction works correctly, and updates the TestFDIV variable (declared in the System unit) accordingly. For subsequent floating-point divide operations, the value stored in TestFDIV is used to determine what action to take.
-1 means that FDIV instruction has been tested and found to be flawed.
0 means that FDIV instruction has not yet been tested.
1 means that FDIV instruction has been tested and found to be correct.
For processors that do not exhibit the FDIV flaw, enabling this option results in only a slight performance degradation. For a flawed Pentium processor, floating-point divide operations may take up to three times longer in the enabled state but always produce correct results. In the disabled (equivalent to {$U-}) state, floating-point divide operations are performed using in-line FDIV instructions. This results in optimum speed and code size, but may produce incorrect results on flawed Pentium processors. You should use the disabled state only in cases where you are certain that the code is not running on a flawed Pentium processor.  
Record field alignment 
Controls alignment of fields in Delphi record types and class structures.
If you select option 1 (equivalent to {$A1}) or disable the option (equivalent to {$A-}), fields are never aligned. All record and class structures are packed.
If you select 2 (equivalent to {$A2}), fields in record types that are declared without the packed modifier and fields in class structures are aligned on word boundaries.
If you select option 4 (equivalent to {$A4}), fields in record types that are declared without the packed modifier and fields in class structures are aligned on double-word boundaries.
If you select 8 (equivalent to {$A8} or {$A+}), fields in record types that are declared without the packed modifier and fields in class structures are aligned on quad word boundaries. Regardless of the state of the $A directive, variables and typed constants are always aligned for optimal access. By setting the option to 8, execution is faster.  
Codepage 
Enter the codepage for your application's language. Codepage is a decimal number representing a specific character encoding table, and there are standard values for various languages.  

 

Syntax options items 
Description 
Strict var-strings 
This option (equivalent to $V directive) is meaningful only for Delphi code that uses short strings, and is provided for backwards compatibility with early versions of Delphi and CodeGear Pascal. The option controls type checking on short strings passed as variable parameters. When enabled (equivalent to {$V+}), strict type checking is performed, requiring the formal and actual parameters to be of identical string types. When disabled (equivalent to {$V-}) (relaxed), any short string type variable is allowed as an actual parameter, even if the declared maximum length is not the same as that of the formal parameter.  
Complete boolean eval 
Switches between the two different models of Delphi code generation for the AND and OR Boolean operators. When enabled (equivalent to {$B+}), the compiler generates code for complete Boolean expression evaluation. This means that every operand of a Boolean expression built from the AND and OR operators is guaranteed to be evaluated, even when the result of the entire expression is already known. When disabled (equivalent to {$B-}), the compiler generates code for short-circuit Boolean expression evaluation, which means that evaluation stops as soon as the result of the entire expression becomes evident in left to right order of evaluation.  
Extended syntax 
Provided for backward compatibility. You should not use this option (equivalent to {$X-} mode) when writing Delphi applications. This option enables or disables Delphi's extended syntax:
Function statements. In the {$X+} mode, function calls can be used as procedure calls; that is, the result of a function call can be discarded, rather than passed to another function or used in an operation or assignment. Generally, the computations performed by a function are represented through its result, so discarding the result makes little sense. Sometimes, however, a function is called because it performs a task such as setting the value of a global variable, without producing a useful result.
The Result variable. When enabled (equivalent to {$X+}, the predefined variable Result can be used within a function body to hold the function's return value.
Null-terminated strings. When enabled, Delphi strings can be assigned to zero-based character arrays (array[0..X] of Char), which are compatible with PChar types.  
Typed @ operator 
Controls the types of pointer values generated by the @ operator and the compatibility of pointer types. When disabled (equivalent to {$T-}), the result of the @ operator is always an untyped pointer (Pointer) that is compatible with all other pointer types. When @ is applied to a variable reference in the enabled (equivalent to {$T+}), the result is a typed pointer that is compatible only with Pointer and with other pointers to the type of the variable. When disabled, distinct pointer types other than Pointer are incompatible (even if they are pointers to the same type). When enabled, pointers to the same type are compatible.  
Open parameters 
Meaningful only for code compiled supporting huge strings, and is provided for backwards compatibility with early versions of Delphi and CodeGear Pascal. This option, (equivalent to $P) controls the meaning of variable parameters declared using the string keyword in the huge strings disabled (equivalent to {$H-}) state. When disabled (equivalent to {$P-}), variable parameters declared using the string keyword are normal variable parameters, but when enabled (equivalent to {$P+}), they are open string parameters. Regardless of the setting of this option, the openstring identifier can always be used to declare open string parameters.  
Huge strings 
Delphi for Win32 only. This option (equivalent to the $H directive) controls the meaning of the reserved word string when used alone in a type declaration. The generic type string can represent either a long, dynamically-allocated string (the fundamental type AnsiString) or a short, statically allocated string (the fundamental type ShortString). By default, Delphi defines the generic string type to be the long AnsiString.
All components in the component libraries are compiled in this state. If you write components, they should also use long strings, as should any code that receives data from component library string-type properties. The disabled (equivalent to {$H-}) state is mostly useful for using code from versions of Delphi that used short strings by default. You can locally override the meaning of string-type definitions to ensure generation of short strings. You can also change declarations of short string types to string[255] or ShortString, which are unambiguous and independent of the enabled option.  
Assignable typed constants 
Controls whether typed constants can be modified or not. When enabled (equivalent to {$J+}), typed constants can be modified, and are in essence initialized variables. When disabled (equivalent to {$J-}), typed constants are truly constant, and any attempt to modify a typed constant causes the compiler to report an error. Writable consts refers to the use of a typed const as a variable modifiable at runtime.
Old source code that uses writable typed constants must be compiled with this option enabled, but for new applications it is recommended that you use initialized variables and compile your code with the option disabled.  

 

Target platform items 
Description (only for .NETprojects) 
AnyCPU 
The executable runs on any CPU.  
x86 
The executable runs only on the 32–bit x86 common language runtime.  
x64 
The executable runs only on the 64–bit common language runtime on computers that support the AMD64 or EM64T instruction set.  

 

Runtime errors items 
Description 
Range checking 
Enables or disables the generation of range-checking code. When enabled, (equivalent to {$R+}), all array and string-indexing expressions are verified as being within the defined bounds, and all assignments to scalar and subrange variables are checked to be within range. If a range check fails, an ERangeError exception is raised (or the program is terminated if exception handling is not enabled). Enabling range checking slows down your program and makes it somewhat larger.  
I/O checking 
Enables or disables the automatic code generation that checks the result of a call to an I/O procedure. If an I/O procedure returns a nonzero I/O result when this switch is on, an EInOutError exception is raised (or the program is terminated if exception handling is not enabled). When this switch is off, you must check for I/O errors by calling IOResult.  
Overflow checking 
Controls the generation of overflow checking code. When enabled (equivalent to {$Q+}), certain integer arithmetic operations (+, -, *, Abs, Sqr, Succ, Pred, Inc, and Dec) are checked for overflow. The code for each of these integer arithmetic operations is followed by additional code that verifies that the result is within the supported range. If an overflow check fails, an EIntOverflow exception is raised (or the program is terminated if exception handling is not enabled). This switch is usually used in conjunction with the range checking option ($R switch), which enables and disables the generation of range-checking code. Enabling overflow checking slows down your program and makes it somewhat larger.  

 

Debugging items 
Description 
Debug information 
Enables or disables the generation of debug information. This information consists of a line-number table for each procedure, which maps object-code addresses into source text line numbers. For units, the debug information is recorded in the unit file along with the unit's object code. Debug information increases the size of unit file and takes up additional memory when compiling programs that use the unit, but it does not affect the size or speed of the executable program. When a program or unit is compiled with this option enabled (equivalent to {$D+}), the integrated debugger lets you single-step and set breakpoints in that module. The Include debug info and Map file options (on the Linker page of the Project Options dialog) produce complete line information for a given module only if you've compiled that module with this option set on. This option is usually used in conjunction with the Local symbols option (the $L switch), which enables and disables the generation of local symbol information for debugging.  
Local symbols 
Enables or disables the generation of local symbol information. Local symbol information consists of the names and types of all local variables and constants in a module, that is, the symbols in the module's implementation part and the symbols within the module's procedures and functions. For units, the local symbol information is recorded in the unit file along with the unit's object code. Local symbol information increases the size of unit files and takes up additional memory when compiling programs that use the unit, but it does not affect the size or speed of the executable program. When a program or unit is compiled with this option enabled (equivalent to {$L+}), the integrated debugger lets you examine and modify the module's local variables. Furthermore, calls to the module's procedures and functions can be examined by way of the View | Call Stack. The Include TD32 debug info and Map file options (on the Linker page of the Project Options dialog) produce local symbol information for a given module only if that module was compiled with this option set on. This option is usually used in conjunction with the Debug information option, which enables and disables the generation of line-number tables for debugging. This option is ignored if the compiler has the Debug information option disabled.  
Reference info 
Generates symbol reference information used by the Code Editor and the Project Manager. Corresponds to {$Y}. If Reference info and Definitions only are both checked ({$YD}), the compiler records information about where identifiers are defined. If Reference info is checked but Definitions only is unchecked ({$Y+}), the compiler records information about where each identifier is defined and where it is used. These options have no effect unless Debug information and Local symbols (see above) are selected.  
Definitions only 
See description of Reference info.  
Assertions 
Enables or disables the generation of code for assertions in a Delphi source file. The option is enabled (equivalent to {$C+}) by default. Since assertions are not usually used at runtime in shipping versions of a product, compiler directives that disable the generation of code for assertions are provided. Uncheck this option to disable assertions.  
Use Debug DCUIL/DCUs 
The debug DCUILs (.NET) or DCUs (Win32) contain debug information and are built with stack frames. When this option is checked, the compiler prepends the debug DCUIL/DCU path to the unit search path specified in Debug Source Path on the Directories/Conditionals page.  

 

Documentation items 
Description 
Generate XML Documentation  
Generates a file containing the XML representation in your project directory. Corresponds to the --doc compiler switch.  

 

General item 
Description 
Default 
Saves the current settings as the default for each new project.  

Tip: To display the compiler options in the Messages
window when you compile a project, choose ToolsOptionsEnvironment Options and select \ Show command line. The next time you compile a project, both the command used to compile the project and the response file are displayed in the Messages window. The response file lists the compiler options and the files to be compiled.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!