Clang-enhanced C++ Compilers
Go Up to C++ Compilers
The latest generation of RAD Studio C++ compilers is based on the open-source Clang compiler, which is a front end for the LLVM compiler back end.
RAD Studio provides the following Clang-enhanced C++ compilers:
Compiler | Platform | Clang Version | LLVM Version |
---|---|---|---|
BCC32C | 32-bit Windows | 3.3 | 3.3 |
BCC64 | 64-bit Windows | 3.3 | 3.3 |
BCCIOSARM | 32-bit iOS | 3.3 | 3.3 |
BCCIOSARM64 | 64-bit iOS | 3.3 | 3.5 |
BCCAARM | Android | 3.3 | 3.3 |
Contents
Differences Between Clang-enhanced C++ Compilers and Previous-Generation C++ Compilers
Clang-enhanced C++ compilers have an entirely new code base, and they differ significantly from the RAD Studio previous-generation C++ compilers:
Here are some of the notable differences between Clang-enhanced C++ compilers and the two previous-generation C++ compilers:
- Clang-enhanced C++ compilers are also preprocessors when run with the
-E
switch.- For 64-bit Windows, there is also a separate CPP64.EXE preprocessor.
- Clang-enhanced C++ compilers enforce template two-phase lookup.
- That is, names that are not tied to a dependent type are looked-up in the first phase (before instantiation) and might lead to errors that previous-generation C++ compilers did not report. In the second phase (instantiation), the template code is looked up again to ensure all calls are valid for dependent types. For further information, see Two-phase name lookup for Clang.
Eg: The template might perform calls to functions that might not be present for that particular type.
- Clang-enhanced C++ compilers allow a default argument only in a function declaration.
- Previous-generation C++ compilers allow default arguments in a function pointer or closure declaration as well.
- Clang-enhanced C++ compilers do not allow the use of sizeof in a preprocessor directive, such as
#if sizeof(ATypeName) > 20
. - Clang-enhanced C++ compilers are stricter about conversions.
- For example, converting string constants to
char *
generates a warning (conversion from string literal tochar *
is deprecated). On the other hand, initializing achar *
with anunsigned char *
results in a plain error (Cannot initialize a variable of type 'char *' with an rvalue of typeBYTE *
, also known asunsigned char *
).
- For example, converting string constants to
- Clang-enhanced C++ compilers do not allow you to mix
__try
withcatch
: this is becausecatch
must be used withtry
; and__try
must be used with__except
and/or__finally
. - Unicode identifiers are not supported by Clang-enhanced C++ compilers.
- CPP32 supports the
-Hp
option and prints header guard information that is used by the Precompiled Header Wizard. - The Unix-style
#line
is not the default#line
of CPP32, and so forth. - Clang-enhanced C++ compilers do not support the final, deprecated and noreturn C++11 attributes. See Workaround for C++11 attributes for a workaround in Clang-enhanced C++ compilers.
- Many options of previous-generation C++ compilers are not supported by Clang-enhanced C++ compilers, and vice versa:
For more information, see Differences Between Clang-enhanced C++ Compilers and Previous-Generation C++ Compilers.
How Previous-Generation C++ Compiler Options Translate to Options of Clang-enhanced C++ Compilers
See Project Options Supported by Clang-enhanced C++ Compilers.
Common Issues When Compiling a Previous-Generation C++ Compiler Project Using Clang-enhanced C++ Compilers
You are likely to encounter new errors due to the ANSI-compliant strictness of Clang-enhanced C++ compilers.
For more information, see:
- Errors and Warnings of Clang-enhanced C++ Compilers
- Differences Between Clang-enhanced C++ Compilers and Previous-Generation C++ Compilers
Support for Precompiled Headers
Clang-enhanced C++ compilers support the use of one precompiled header, named by default <project><n>PCH.h
.
For further information, see Using Precompiled Headers with Clang-enhanced C++ Compilers.
Predefined Macros
The predefined macros supported by the Clang-enhanced compilers are numerous. For example, BCCIOSARM supports defines such as __APPLE__
and __BCCPLUSPLUS__
.
To display all the predefined macros that are supported, use the command-line interface of your compiler as follows:
echo | <compiler> -E -dM -
The -E
option runs the preprocessor only. -dM
dumps all macros defined during preprocessing and stops. The final -
takes input from stdin, which is sent through the pipe from the empty echo
.
For more information, see Predefined Macros.
Keywords
This section contains an alphabetical list of C++ keywords that require special considerations when used with Clang-enhanced C++ compilers or are not supported by these compilers.
Supported | Not supported |
---|---|
See Workaround for C++11 Attributes (Clang-enhanced C++ Compilers) to learn how to replace the functionality of keywords that are not supported in Clang-enhanced C++ compilers.
Automatic Reference Counting May Be Enabled by Default
The LLVM-based Delphi compilers use automatic reference counting (ARC). If the Delphi compiler for a certain target platform is based on LLVM, the matching Clang-enhanced C++ compiler automatically enables ARC. Enabling ARC is equivalent to passing the -fborland-auto-refcount
switch to the command-line interface of the C++ compiler.
The following table shows which Clang-enhanced C++ compilers have ARC enabled by default:
Platform | Delphi Compiler | C++ Compiler | ARC Enabled by Default |
---|---|---|---|
32-bit Windows |
No | ||
64-bit Windows |
No | ||
32-bit iOS |
Yes | ||
64-bit iOS |
Yes | ||
Android |
Yes |
- Note: Do not disable ARC on the command line. It is required for working with the FireMonkey and RTL frameworks.
Using Parallel Compilation
Parallel compilation allows compilers to process several source files simultaneously, using separate cores of the system processor, to significantly decrease compilation time.
To enable parallel compilation in the IDE for a certain C++ project, open the target project and follow these steps:
- Select Project > Options > C++ Compiler, and enable the "Enable batch compilation" option under General Compilation.
- Select Project > Options > Project Properties and:
- Enable the "Run C++ compiler in a separate process" option.
- Select the number of parallel subprocesses that you want to use.
- Note: The number of subprocesses that you choose cannot be higher than the number of cores of your CPU.
Topics
- BCC32C
- BCC64
- BCCIOSARM
- BCCIOSARM64
- BCCAARM
- Differences Between Clang-enhanced C++ Compilers and Previous-Generation C++ Compilers
- Project Options Supported by Clang-enhanced C++ Compilers
- Options Not Supported by Clang-enhanced C++ Compilers
- Precompiled Headers Command Line Options for Clang-enhanced C++ Compilers
- Using Precompiled Headers with Clang-enhanced C++ Compilers
- Errors and Warnings of Clang-enhanced C++ Compilers
See Also
- C++11 Features Supported by RAD Studio Clang-enhanced C++ Compilers
- C++11 Language Features Compliance Status
- Command-Line Interfaces of Clang-enhanced C++ Compilers