Predefined Macros
Go Up to The Preprocessor Index
The C++ compiler predefines certain global identifiers, known as manifest constants. Most global identifiers begin and end with two underscores (__).
- Note: For readability, underscores are often separated by a single blank space. In your source code, you should never insert whitespace between underscores.
For macros whose value takes the form of 0x0nnn
, the version number (nnn
) is determined by the version number of the associated C++ compiler executable. Beginning with the XE release, you can verify the version number using the --version
option to BCC32.EXE.
Macro | Value | Description |
---|---|---|
__ANDROID__ |
Defined only in compilers that support cross compiling with an Android product as the target platform: | |
__APPLE__ |
Defined only in compilers that support cross compiling with an Apple product as the target platform: | |
__arm__ |
Defined only in compilers that support cross compiling for the 32-bit ARM compiler architecture: | |
__arm64__ |
Defined only in compilers that support cross compiling for the ARM64 compiler architecture: | |
__BCOPT__ |
1 |
Defined only in compilers that support optimization, therefore always defined. |
__BCPLUSPLUS__ |
Values are listed in C++ Compiler Versions in this topic. |
Defined if you've selected C++ compilation; will increase in later releases. |
__BOOL__ |
1 |
Indicates that the bool keyword is accepted. |
__BORLANDC__ |
Values are listed in C++ Compiler Versions in this topic. |
Version number. |
__CDECL__ |
1 |
Defined if Calling Convention is set to cdecl; otherwise undefined. |
_CHAR_UNSIGNED |
1 |
Undefined by default. Using the -K switch to make the default character unsigned causes this macro to be defined. Ultimately, the -K option controls how a char is extended when converted to an int. By default, the compiler sign-extends, but if you enable _CHAR_UNSIGNED_, then the compiler zero-extends characters when converting to int. |
__clang__ |
1 |
Defined if a Clang-enhanced C++ compiler is in use. See Clang Builtin Macros. |
__CODEGEARC__ |
Values are listed in C++ Compiler Versions and in this topic. |
Version number. |
__CODEGEARC_VERSION__ |
|
This internal macro expands to an integer that encodes the compiler's major version, minor version, and an internal number. See Example of __CODEGEARC_VERSION__ Macro. |
__CODEGUARD__ |
Defined whenever one of the CodeGuard compiler options is used; otherwise it is undefined. | |
__CONSOLE__ |
1 |
When defined, the macro indicates that the program is a console application. |
_CPPUNWIND |
1 |
Enable stack unwinding. This is true by default; use -xd-!ALink(OSCGExceptions1) to disable. |
__cplusplus |
1 |
Defined if in C++ mode; otherwise, undefined. |
__DATE__ |
String literal |
Date when processing began on the current file. |
__DLL__ |
1 |
Defined whenever the -WD compiler option is used; otherwise it is undefined. |
__FILE__ |
String literal |
Name of the current file being processed. |
__FLAT__ |
1 |
Defined when compiling in 32-bit flat memory model. |
__FUNC__ or __FUNCTION__ |
String literal |
Name of the current function being processed. More details. |
__LINE__ |
Decimal constant |
Number of the current source file line being processed. |
__MACH__ |
Defined only in compilers that support cross compiling with a target of MAC OSX. | |
_M_IX86 |
0x12c |
Always defined. The default value is 300. You can change the value to 400 or 500 by using the /4 or /5 compiler options. |
__MT__ |
1 |
Defined only if the -tWM option is used. It specifies that the multithread library is to be linked. |
__PASCAL__ |
1 |
Defined if Calling Convention is set to Pascal; otherwise undefined. |
_PUSHPOP_SUPPORTED |
1 |
Always defined; allows Microsoft standard headers to use push and pop to verify whether a feature is supported. |
_STDCALL_SUPPORTED |
1 |
Always defined; defines the Microsoft stdcall calling convention. |
__STDC__ |
1 |
Defined if you compile with the -A compiler option; otherwise, it is undefined. |
__TCPLUSPLUS__ |
Values are listed in C++ Compiler Versions in this topic. |
Version number. |
__TEMPLATES__ |
1 |
Defined as 1 for C++ files (meaning that templates are supported); otherwise, it is undefined. |
__TIME__ |
String literal |
Time when processing began on the current file. |
__TLS__ |
1 |
Thread Local Storage. Always true. |
__TURBOC__ |
Values are listed in C++ Compiler Versions and in this topic. |
Will increase in later releases. |
_UNICODE and UNICODE |
Defined for C++ programs that use the VCL. | |
_WCHAR_T |
Defined only for C++ programs to indicate that wchar_t is an intrinsically defined data type. | |
_WCHAR_T_DEFINED |
Defined only for C++ programs to indicate that wchar_t is an intrinsically defined data type. | |
_Windows |
1 |
Defined when compiling on the Windows platform. |
__WIN32__ |
1 |
Defined for console and GUI applications on the 32-bit Windows platform. |
_WIN64 |
1 |
Defined for console and GUI applications on the 64-bit Windows platform. |
- Notes:
- The predefined macros __DATE__, __FILE__ , __FUNC__, __LINE__, __STDC__, and __TIME__ cannot be redefined or undefined.
- In order to check the entire list of predefined macros supported by Clang-enhanced C++ compilers, see predefined macros.
C++ Compiler Versions in Predefined Macros
The macros defined for the C++ compiler (such as __CODEGEARC__) have the following version numbers:
- 0x0670 for Appmethod C++ 1.13 (BCC32, BCC64, BCCOSX, and BCCIOSARM).
- 0x0680 for Appmethod C++ 1.14 (BCC32, BCC64, BCCOSX, BCCIOSARM, and BCCAARM).
- 0x0690 for Appmethod C++ 1.15 (BCC32, BCC64, BCCOSX, BCCIOSARM, and BCCAARM).
- 0x0700 for Appmethod C++ 1.16 (BCC32, BCC64, BCCOSX, BCCIOSARM, BCCIOSARM64, and BCCAARM).
- 0x0710 for Appmethod C++ 1.17 (BCC32C, BCC32, BCC64, BCCOSX, BCCIOSARM, BCCIOSARM64, and BCCAARM).
See also Conditional compilation (Object Pascal).
Macros Defined Elsewhere
The following macros are defined for backwards-compatibility when you #include System.hpp
:
Macro | Value | Description |
---|---|---|
ANSISTRING_AS_TEMPLATE |
AnsiString type is defined as a template class, AnsiString<T>. | |
_STRINGCHECKS_OFF |
In past releases, C++ programs expected the Object Pascal compiler to not set the STRINGCHECKS directive. The Object Pascal compiler no longer supports the STRINGCHECKS directive, so the related _STRINGCHECKS_OFF C++ macro is unnecessary and is no longer set. Therefore if you are migrating pre-2009 code to the current version, you need to update the event-handler signature (because a pre-2009 event handler expects AnsiString, while the run time now sends UnicodeString). See Unicode in Appmethod. |