Differences Between Clang-based C++ Compilers and Previous-Generation C++ Compilers
Go Up to Clang-based C++ Compilers
- 1 Compiler Options
- 2 Stricter C++ Compiler
- 3 Warnings and Error Messages
- 4 Predefined Macros
- 5 #include Paths and Lookup
- 6 Precompiled Headers
- 7 Object and Library File Format
- 8 __property: Compound and Chained Assignment
- 9 Deprecated BCC32 Extensions and Keywords
- 10 Unsupported BCC32 Attributes
- 11 Unicode Identifiers Are Not Supported
- 12 Inline Assembly
- 13 See Also
Clang-based C++ compilers use an almost completely different set of compiler options, and a different way to express multiple values for the same option.
Stricter C++ Compiler
Clang-based C++ compilers are more compliant with C++ language standards than BCC32. They provide C++11 support, but they are also more strict. See Stricter C++ Compilers (Clang-based C++ Compilers).
Warnings and Error Messages
In addition to new, more specific and detailed warnings and error messages, Clang-based C++ compilers phrase messages for conditions detected by BCC32 in a different way.
For more information, see Errors and Warnings of Clang-based C++ Compilers.
Using Clang-based C++ compilers you can get all the predefined macros directly from the preprocessor.
The NO_STRICT type checking scheme is not supported in Clang-based C++ compilers. If you have existing projects that use the NO_STRICT conditional define, you need to remove it.
For more information and instructions for removing NO_STRICT, see: C++ Applications Use STRICT Type Checking.
#include Paths and Lookup
You might need to
#include headers differently with Clang-based compilers.
For example, Clang-based C++ compilers do not find headers specified with semi-absolute paths as BCC32 does. Given that 'myOtherFile' is located at C/myProjectsDir/myOtherApp, the following references in a .CPP file are accepted by both Clang-based C++ compilers and BCC32:
#include "c:/myProjectsDir/myApp/mySource.h" // Absolute path. #include "../myApp/mySource.h" // Relative path.
However, the following yields an error with Clang-based C++ compilers, but it is accepted by BCC32:
#include "/myProjectsDir/myApp/mySource.h" // Semi-absolute path.
Clang-based C++ compilers emit the following error:
[<compiler> Fatal Error] myOtherFile.cpp(27): '/myProject/myApp/mySource.h' file not found
For more information, see Clang-based C++ Compilers, #include Paths and Lookup.
Compared to BCC32, precompiled headers work a little differently for Clang-based C++ compilers. Each C++ project can have only one precompiled header, and a default precompiled header (named projectPCHn.h) is generated for each new C++ project.
For more information, see the following topics:
- Using Precompiled Headers with Clang-based C++ Compilers
- Precompiled Headers Command Line Options for Clang-based C++ Compilers
Object and Library File Format
- BCC32 and its associated tools use OMF in
- Clang-based C++ compilers use ELF in
This difference means, for example, that when you migrate a 32-bit Windows applications you must change references to
.obj files to be
__property: Compound and Chained Assignment
Clang-based C++ compilers support compound assignment of
__property, while BCC32 does not.
The objects of the keyword
__property are not like fields or members. They should be used in simple assignments.
Although both BCC32 and the Appmethod Clang-based C++ compilers allow
__property to be used in compound assignments such as:
Form1->Caption += DateToStr(Now());
BCC32 only invokes the getter, not the setter. Therefore we recommend that you avoid such constructs when targeting multiple platforms.
None of these compilers support the usage of __property in chained assignment, as in:
Button2->Caption = Button1->Caption = DateToStr(Now()); // Error
Deprecated BCC32 Extensions and Keywords
No-underscore and single-underscore compiler keyword extensions are either unsupported or deprecated in Clang-based C++ compilers. Use the double-underscore versions (they are also supported in BCC32):
__fastcall, which is now Microsoft-style, not Borland-style.
__fortran: Not supported, obsolete.
__asm: Inline assembly is not supported.
Unsupported BCC32 Attributes
See Workaround for C++0x Attributes (noreturn and final).
Unicode Identifiers Are Not Supported
Although Unicode is supported in literal strings and file names, Unicode in identifiers is not allowed.
Clang-based C++ compilers allow inline assembly with these caveats:
- You cannot mix assembly with C++ code.
- Do not touch the stack pointer (RSP).
- The assembler must use the AT&T line-by-line syntax, not the more familiar block-of-Intel syntax. For more information, see GCC-Inline-Assembly-HOWTO.
Clang-based C++ compilers support inline assembly in a different style than the inline assembly supported by BCC32:
- Different Assembly syntax:
- The Assembly syntax supported by Clang-based C++ compilers is line-by-line AT&T syntax, not the more familiar block-of-Intel syntax.
- Potential exception handling and debugging problems:
- The exception handling of the compiler places additional burdens on hand-written Assembly code intermixed with C++. Functions written entirely in assembly (with a separate assembler like NASM or MASM) can be linked into your program. However, there are inherent issues (potential exception handling and debugging problems) that you should know before you start.
- The reasons for these issues for inline assembly can be summarized as: pdata. Lack of support for inline assembly is fairly common; for exceptions (and debugging) to work, code has to generate data structures (pdata) that describe each function and what must be unwound if an exception is thrown. After you insert inline assembly, the compiler is unaware of finer details (like any extra stack space the inline assembly allocated). Inline assembly (that is, mixing assembly and C/C++ code) makes it impossible for the compiler to accurately generate the pdata structures. For more information about pdata, see http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
For a code example illustrating how to use inline assembly with a Clang-based C++ compiler, see Inline Assembly with BCC64 (C++).
For more information about assembly with Clang-based C++ compilers, see: