C++ Compiler

From RAD Studio
Jump to: navigation, search

Go Up to Project Options Dialog Box


Project > Options > C++ Compiler

Use this dialog box to set C++ Compiler options.

Options Description

Target, Apply, Save

See Target Options.

Common items

See Common Items on Project Options Pages.

C++ Compilation Options

Item Description Compiler switches
bcc32 bcc32c bcc64 bccosx bcciosarm bcciosarm64 bccaarm

Enable exceptions

Sets C++ exception handling. If this option is disabled (-x-) and you attempt to use exception handling routines in your code, the compiler generates error messages during compilation.

Disabling this option makes it easier for you to remove exception handling information from programs; this might be useful if you are porting your code to other platforms or compilers. Disabling this option turns off only the compilation of exception handling code; your application can still include exception code if you link object and library files that were built with exceptions enabled (such as the C++Builder run-time libraries).

Default = True

Destructor cleanup
(-xd)

When this option is set, and an exception is thrown, destructors are called for all automatically declared objects between the scope of the catch and throw statements.

In general, when you set this option, you should also set Enable Run-time Type Information (-RT) as well. Destructors are not automatically called for dynamic objects allocated with new, and dynamic objects are not automatically freed.

Default = True

Fast exception prologs
(-xf)

Expands inline code for every exception handling function. This option improves performance at the cost of larger executable file sizes.

Default = False

Global destructor count
(-xdg)

Use global destructor count (for compatibility with older versions of the compiler).

Default = False

Hide exception variables
(-xv)

The compiler treats the following exception handling symbols as special:

  • __exception_info
  • __exception_code
  • __abnormal_termination

These are all mapped to special compiler/RTL constructs for Structured Exception Handling (SEH) code. If you are not using SEH, and you have variables of this name, it means that you could not reference those variables, and your code would not compile. This option causes the compiler to hide its special symbols in this event so that you can use variables of this name.

Default = False

Location information
(-xp)

When this option is set, run-time identification of exceptions is available, because the compiler provides the file name and source code line number where the exception occurred. This enables the program to use the __ThrowFileName global function to obtain the file where the exception occurred and the __ThrowLineNumber global function to access the line number from where the C++ exception was thrown.

Default = False

No DLL/MT destructor cleanup
(-xds)

Does not perform DLL or multi-threaded destructor cleanups.

Default = False

Slow exception epilogs
(-xs)

When this option is set, the exception handling epilogue code is not expanded inline. This option decreases performance slightly.

Default = False

Enable exceptions
-x

Destructor cleanup
-xd

Fast exception prologs
-xf

Global destructor count
-xdg

Hide exception variables
-xv

Location information
-xp

No DLL/MT destructor cleanup
-xds

Slow exception epilogs
-xs
Enable exceptions
-fexceptions

Platform not supported


Platform not supported



Platform not supported



Platform not supported



Platform not supported


Platform not supported



Platform not supported
N/A



Platform not supported

Platform not supported


Platform not supported


Platform not supported


Platform not supported

Platform not supported


Platform not supported
Enable exceptions
-x

Destructor cleanup
-xd

Fast exception prologs
-xf

Global destructor count
-xdg

Hide exception variables
-xv

Location information
-xp

No DLL/MT destructor cleanup
-xds

Slow exception epilogs
-xs
N/A



Platform not supported

Platform not supported


Platform not supported


Platform not supported


Platform not supported

Platform not supported


Platform not supported
N/A



Platform not supported


Platform not supported



Platform not supported



Platform not supported



Platform not supported


Platform not supported



Platform not supported
N/A



Platform not supported

Platform not supported


Platform not supported


Platform not supported


Platform not supported

Platform not supported


Platform not supported

Enable RTTI

Causes the compiler to generate code that allows run-time type identification (RTTI).
In general, if you set Enable Destructor Cleanup (-xd) you need to set this option as well.

Default = True

-RT -frtti N/A -RT N/A N/A N/A

Honor member precision

The compiler uses the declared precision for member pointer types. Use this option when a pointer to a derived class is explicitly cast as a pointer-to-member of a simpler base class (when the pointer is actually pointing to a derived class member).

Default = False

-Vmp Platform not supported Platform not supported -Vmp Platform not supported Platform not supported Platform not supported

Member pointers

Smallest possible
(-Vmd)

Member pointers use the smallest possible representation that allows them to point to all members of their particular class. If the class is not fully defined at the point where the member pointer type is declared, the most general representation is chosen by the compiler and a warning is issued.

Multiple inheritance
(-Vmm)
Member pointers can point to members of multiple inheritance classes (with the exception of virtual base classes).

Single inheritance
(-Vms)
Member pointers can point only to members of base classes that use single inheritance.

Default*
No options set for member pointers.
This is the default.

Smallest possible
-Vmd


Multiple inheritance
-Vmm


Single inheritance
-Vms

Platform not supported


Platform not supported



Platform not supported
Platform not supported

Platform not supported


Platform not supported
Smallest possible
-Vmd


Multiple inheritance
-Vmm


Single inheritance
-Vms

Platform not supported

Platform not supported


Platform not supported
Platform not supported


Platform not supported



Platform not supported
Platform not supported

Platform not supported


Platform not supported

Template generation

Default
(-Jgd)*
The compiler generates public (global) definitions for all template instances. If more than one module generates the same template instance, the linker automatically merges duplicates to produce a single copy of the instance. To generate the instances, the compiler must have available the function body (in the case of a template function) or the bodies of member functions and definitions for static data members (in the case of a template class), typically in a header file.

This is a convenient way of generating template instances. This is the default.

External
(-Jgx)
The compiler generates external references to all template instances. If you use this option, all template instances that need to be linked must have an explicit instantiation directive in at least one other module.

Default
-Jgd

External
-Jgx
Platform not supported

Platform not supported
Platform not supported
Platform not supported
Default
-Jgd

External
-Jgx
Platform not supported
Platform not supported
Platform not supported

Platform not supported
Platform not supported
Platform not supported

Virtual tables

Smart
(-V)*
Generates common C++ virtual tables and out-of-line inline functions across the modules in your application. As a result, only one instance of a given virtual table or out-of-line inline function is included in the program. The Smart option generates the smallest and most efficient executables, but produces .OBJ and .ASM files compatible only with C++Builder linkers and assemblers. This is the default.

External
(-V0)
Generate external references to virtual tables. If you do not want to use the Smart option, use the External and Public options to produce and reference global virtual tables. When you use this option, one or more of the modules comprising the program must be compiled with the Public option to supply the definitions for the virtual tables.

Public
(-V1)
Public produces public definitions for virtual tables. When using the External option (-V0) at least one of the modules in the program must be compiled with the Public option to supply the definitions for the virtual tables. All other modules should be compiled with the External option to refer to that Public copy of the virtual tables.

Default = Smart

Smart
-V

External
-V0

Public
-V1
Platform not supported

Platform not supported

Platform not supported
Platform not supported
Platform not supported
Platform not supported
Smart
-V

External
-V0

Public
-V1
Platform not supported
Platform not supported
Platform not supported
Platform not supported

Platform not supported

Platform not supported
Platform not supported
Platform not supported
Platform not supported

Classic Compiler

Classic Compiler options Description Compiler switches
bcc32 bcc32c bcc64 bccosx bcciosarm bcciosarm64 bccaarm

Use 'classic' Borland compiler

Enables either the classic BCC32 compiler or the clang-enhanced BCC32C compiler as the C++ compiler for 32-bit Windows platforms.

Use this option to switch a project from BCC32 to BCC32C and vice versa. You can set this option to:

  • True: BCC32 is enabled as the C++ compiler for projects that target 32-bit Windows platforms.
  • False: BCC32C is enabled as the C++ compiler for projects that target 32-bit Windows platforms.

Default = True

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

General Compilation Options

General Compilation options Description Compiler switches
bcc32 bcc32c bcc64 bccosx bcciosarm bcciosarm64 bccaarm

Short enums

Tells the 64-bit compiler to use minimally sized enums.

Allocate to an enum type only as many bytes as it needs for the declared range of possible values.

Default = False

Interger-sized enums option

Interger-sized enums option

-fshort-enums

Interger-sized enums option

N/A
-fshort-enums

N/A
-fshort-enums

N/A
-fshort-enums

Calling convention

Pascal
(-p)
Tells the compiler to generate a Pascal calling sequence for function calls (do not generate underbars, all uppercase, calling function cleans stack, pushes parameters left to right). This is the same as declaring all subroutines and functions with the __pascal keyword. The resulting function calls are usually smaller and faster than those made with the C (-pc) calling convention. Functions must pass the correct number and type of arguments. You can use the __cdecl, __fastcall, or __stdcall keyword to specifically declare a function or subroutine using another calling convention.

C
(-pc)*
Tells the compiler to generate a C calling sequence for function calls (generate underbars, case sensitive, push parameters right to left). This is the same as declaring all subroutines and functions with the __cdecl keyword. Functions declared using the C calling convention can take a variable parameter list (the number of parameters does not need to be fixed).
You can use the __pascal, __fastcall, or __stdcall keyword to specifically declare a function or subroutine using another calling convention. This is the default.

_msfastcall
(-pm)
Tells the compiler to substitute the __msfastcall calling convention for any function without an explicitly declared calling convention.

Fastcall (register)
(-pr)
Forces the compiler to generate all subroutines and all functions using the Register parameter-passing convention, which is equivalent to declaring all subroutines and functions with the __fastcall keyword. With this option enabled, functions or routines expect parameters to be passed in registers.

You can use the __pascal, __cdecl, or __stdcall keyword to specifically declare a function or subroutine using another calling convention.

stdcall
(-ps)
Tells the compiler to generate a stdcall calling sequence for function calls (does not generate underscores, preserve case, called function pops the stack and pushes parameters right to left). This is the same as declaring all subroutines and functions with the __stdcall keyword. Functions must pass the correct number and type of arguments.

You can use the __cdecl, __pascal, __fastcall keyword to specifically declare a function or subroutine using another calling convention.

Default = C (-pc)

Pascal
-p

C
-pc

_msfastcall
-pm

Fastcall(register)
-pr

stdcall
-ps

Platform not supported

-mcdecl


Platform not supported

-mfastcall


-mrtd, -mstdcall

Platform not supported

-mcdecl


Platform not supported

-mfastcall


-mrtd, -mstdcall

Pascal
-p

C
-pc

_msfastcall
-pm

Fastcall(register)
-pr

stdcall
-ps

Platform not supported

-mcdecl


Platform not supported

-mfastcall


-mrtd, -mstdcall
Platform not supported

-mcdecl


Platform not supported

-mfastcall


-mrtd, -mstdcall
Platform not supported

-mcdecl


Platform not supported

-mfastcall


-mrtd, -mstdcall

Data Alignment

Byte
(-a1)
Does not force alignment of variables or data fields to any specific memory boundaries. The compiler aligns data at even or odd addresses, depending on the next available address. While byte alignment produces more compact programs, the programs tend to run slower. The other data alignment options increase the speed at which 80x86 processors fetch and store data.

Word
(-a2)
2 byte data alignment. Aligns non-character data at even addresses. Automatic and global variables are aligned properly. char and unsigned char variables and fields can be placed at any address; all others are placed at even-numbered addresses.

Double word
(-a4)
4 byte data alignment. Aligns non-character data at 32-bit word (4-byte) boundaries. Data type sizes of less than 4 bytes are aligned on their type size.

Quad word
(-a8)*
8 byte data alignment. Aligns non-character data at 64-bit word (8-byte) boundaries. Data with type sizes of less than 8 bytes are aligned on their type size. This is the default.

Paragraph
(-a16)
16 byte data alignment. Aligns non-character data at 128-bit (16-byte) boundaries. Data with type sizes of less than 16 bytes are aligned on their type size.

Default = Quad word (8)

Byte
-a1

Word
-a2

Double word
-a4

Quad word
-a8

Paragraph
-a16

-fpack-struct=1


-fpack-struct=2


-fpack-struct=4


-fpack-struct=8


-fpack-struct=16

N/A


N/A


N/A


N/A


N/A

Byte
-a1

Word
-a2

Double word
-a4

Quad word
-a8

Paragraph
-a16

N/A


N/A


N/A


N/A


N/A
N/A


N/A


N/A


N/A


N/A
N/A


N/A


N/A


N/A


N/A

Disable C++ access control

Tells the compiler not to enforce access control. That is, the compiler does not emit an error if a protected or private member is accessed when it should not be accessible. Use this option if you had code that BCC32 allowed, but BCC64 treats as violating access control (or better, update your code to match the rule used by BCC64).

Default = False

Platform not supported

N/A

-fno-access-control

Platform not supported

N/A N/A N/A

Enable batch compilation

Enables batch compilation.

When this option is enabled, all the source modules are passed to the C++ compiler on the same command line, instead calling the compiler once for each source module. For batch compiles, build events are generated for the entire batch compile, not for single files. Similarly, a batch compile uses one set of project options, with no per-file overrides allowed.

If you are using a Clang-enhanced C++ compiler, you can use "Enable batch compilation" in combination with "Run C++ compiler in a separate process" to enable parallel compilation. Clang-enhanced compilers for 32-bit platforms stop the batch compilation after a file fails to compile.

Default = off

Maximum errors
(-j)

Causes batch compilation to stop after the specified number of errors has been detected. You can enter any number from 0 through 255.

Default = 1

Entering 0 causes compilation to continue until the end of the file or this warning limit has been reached, whichever comes first.

Maximum warnings
(-g)

Causes batch compilation to stop after the specified number of warnings has been detected. You can enter any number from 0 through 255.

Default = 255

Entering 0 causes compilation to continue until either the end of the file or this error limit has been reached, whichever comes first.

Stop on first error
(-jb)

Stops batch compilation after the first file that causes errors. For example:

BCC32.exe -c -gb *.ccp
BCC32.exe -c -gb file1.cpp file2.cpp

Without the -jb flag, batch compilations can continue to the next scheduled file, even after an earlier file has caused an error.

Maximum errors
-j

Maximum warnings
-g

Stop on first error
-jb

-ferror-limit


Platform not supported


Platform not supported
N/A


Platform not supported


Platform not supported

Maximum errors
-j

Maximum warnings
-g

Stop on first error
-jb

N/A


Platform not supported


Platform not supported
N/A


Platform not supported


Platform not supported
N/A


Platform not supported


Platform not supported

Extended error info

The compiler generates more extended information on errors.

Default = False

-Q

Platform not supported

Platform not supported

-Q Platform not supported Platform not supported Platform not supported

Force C++ compile

Causes the compiler to compile all source files as C++ files, regardless of their extension.

Default = False

-P

-x c++

-x c++

-P

-x c++

-x c++

-x c++

Instruction set

80386
(-3)*
Generates 80386 protected-mode compatible instructions. This is the default.

80486
(-4)
Generates i486 protected-mode compatible instructions.

Pentium
(-5)
Generates Pentium instructions. While this option increases the speed at which the application runs on Pentium machines, expect the program to be a bit larger than when compiled with the 80386 or i486 option. Also, Pentium-compiled code sustains a performance hit on non-Pentium systems.

Pentium Pro
(-6)
Generates Pentium Pro instructions.

Default = 80386

80386
-3

80486
-4

Pentium
-5

Pentium Pro
-6

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

80386
-3

80486
-4

Pentium
-5

Pentium Pro
-6

Platform not supported

Platform not supported

Platform not supported

Platform not supported
Platform not supported

Platform not supported

Platform not supported

Platform not supported
Platform not supported

Platform not supported

Platform not supported

Platform not supported

Integer-sized enums

Allocates a whole word (a four-byte int for 32-bit programs) for enumeration types (variables of type enum).

When this option is off (-bi-), the compiler allocates the smallest integer that can hold the enumeration values: the compiler allocates an unsigned or signed char if the values of the enumeration are within the range of 0 through 255 (minimum) or -128 through 127 (maximum), or an unsigned or signed short if the values of the enumeration are within the following ranges: 0..65535 or -32768..32767.

The compiler allocates a four-byte int (32-bit) to represent the enumeration values if any value is out of these ranges.

Default = True

-bi

-fshort-enums

N/A

-bi

N/A N/A N/A

Integer-typed enums

Enables Integer-sized enums (-bi, described above) and treats enums as ints from a typechecking point of view (relaxes typechecking for enums).
When this option is off (-b-), the compiler makes sizeof(enum x) as small as possible and applies enum rules for type checking.

Default = False

-b

-fshort-enums

N/A

-b

N/A N/A N/A

Language compliance

ANSI
(-A)

Use ANSI keywords and extensions. Compiles C and C++ ANSI-compatible code, allowing for maximum portability. Non-ANSI keywords are ignored as keywords.

GNU
(-AG)

Use keywords and extensions of Gcc, the GNU compiler collection, which is distributed by the Free Software Foundation at http://gcc.gnu.org/. Tells the compiler to recognize specific GNU keywords and extensions, such as __attribute__, __const, __inline__, __signed__. See GNU Attributes.

K & R
(-AK)

Use Kernighan and Ritchie (KR) keywords and extensions. Tells the compiler to recognize only the KR extension keywords and treat any C++ extension keywords as normal identifiers.

Borland/CodeGear
(also -A-) (-AT)*

Use Borland/CodeGear/Embarcadero C++ keywords and extensions. Tells the compiler to recognize extensions to the C language keywords, including near, far, huge, asm, cdecl, pascal, interrupt, _export, _ds, _cs, _ss, _es, and the register pseudovariables ( _AX, _BX, and so on). This is the default.

Unix System V
(-AU)

Use UNIX System V keywords and extensions. Tells the compiler to recognize only UNIX V keywords and treat any of the Borland/CodeGear/Embarcadero C++ extension keywords as normal identifiers.

Hint: If you get declaration syntax errors from your source code, check that this option is set to Borland/CodeGear.

Default = Borland/CodeGear.

ANSI
-A

GNU
-AG

K & R
-KR

Borland/CodeGear
-AT

Unix System V
-AU

-fno-borland-extensions

Platform not supported

Platform not supported

-fborland-extensions

Platform not supported

N/A


Platform not supported

Platform not supported

N/A


Platform not supported

ANSI
-A

GNU
-AG

K & R
-KR

Borland/CodeGear
-AT

Unix System V
-AU

N/A


Platform not supported

Platform not supported

N/A


Platform not supported
N/A


Platform not supported

Platform not supported

N/A


Platform not supported
N/A


Platform not supported

Platform not supported

N/A


Platform not supported

Register variables

None
(-r-)*
Disables the use of register variables. Tells the compiler not to use register variables, even if you have used the register keyword. This is the default.

Explicit
(-rd)
Use register variables only if you use the register keyword and a register is available. Use this option or the Always option (-r) to optimize the use of registers. You can use -rd in #pragma options.

Always
(-r)
Automatically assign register variables if possible, even when you do not specify a register variable by using the register keyword. Generally, you can use Always, unless you are interfacing with preexisting assembly code that does not support register variables.

Default = None

None
-r-

Explicit
-rd

Always
-r

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

Platform not supported

None
-r-

Explicit
-rd

Always
-r

Platform not supported

Platform not supported

Platform not supported
Platform not supported

Platform not supported

Platform not supported
Platform not supported

Platform not supported

Platform not supported

Set the maximum number of errors to emit before stopping (0 = no limit)

To specify the number of errors to allow for the 64-bit C++ compiler, select the number in this field and type the number you want to set. Default = 1

Platform not supported

N/A

-ferror-limit

Platform not supported

N/A

N/A

N/A

Standard stack frames

Generates a standard stack frame (standard function entry and exit code). This is helpful when debugging since it simplifies the process of stepping through the stack of called subroutines.

When this option is off, any function that does not use local variables and has no parameters is compiled with abbreviated entry and return code. This makes the code smaller and faster.

The Standard Stack Frame option should always be on when you compile a source file for debugging.

Default = True

-k

Platform not supported

Platform not supported

-k

Platform not supported Platform not supported Platform not supported

Child Pages

See Also