4.3. Pre-Defined Macro Symbols¶
Many applications support a variety of configurations that are often administered via the use of pre-defined macro symbols.
While several pre-defined macro symbols supported by the cl2000 compiler are also supported by the c29clang compiler, many are not. For a given cl2000 pre-defined macro symbol that is not supported by the c29clang compiler, there are ways one can successfully transition the use of such a pre-defined symbol to be compatible with the c29clang compiler.
This section of the “Migrating C and C++ Source Code” chapter of the migration guide lists each of the pre-defined macro symbols that are supported in the cl2000 compiler and, if conversion is needed, explains how to modify the C/C++ source to make it compatible with the c29clang compiler.
For details about macro symbols that are pre-defined by the c29clang compiler, see Generic Compiler Pre-Defined Macro Symbols.
4.3.1. Pre-Defined Macro Symbols that are Available in Both cl2000 and c29clang¶
Some pre-defined macro symbols supported by the cl2000 compiler are also supported by the c29clang compiler. The following table identifies those pre-defined macro symbols that are supported by both compilers and require no conversion when migrating an application from cl2000 to c29clang:
Macro Symbol |
Description / Comments |
|---|---|
|
References to the |
|
The The user can also force |
|
References to the |
|
The |
|
References to the |
|
Defined if some level of optimization is specified when the compiler is invoked. The cl2000 compiler allows C/C++ source code to undefine the The c29clang compiler does not support turning off inlining by undefining macros. It additionally supports the |
|
References to the |
|
Both the cl2000 and c29clang compilers
define the |
|
The |
|
The |
|
The |
|
References to the |
|
References to the |
|
The |
4.3.2. Converting cl2000 Pre-Defined Macro Symbols to c29clang Compatible Form¶
Several cl2000 pre-defined macro symbols are not supported by c29clang, but these macro symbols can often be re-written in terms of GCC pre-defined macro symbols that c29clang does support. The following table lists cl2000 pre-defined macro symbols that are not supported by the c29clang compiler, and how they may be converted to a form that is supported by c29clang:
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__little_endian__ |
defined(_LITTLE_ENDIAN_) |
The cl2000 compiler defines the __little_endian__ macro symbol to indicate that the compiler uses little-endian mode. References to __little_endian__ can safely be replaced with a test that evaluates to True, since the C29x architecture does not support big-endian mode.
The c29clang compiler defines the _LITTLE_ENDIAN_ macro symbol in all cases, because only little-endian mode is supported.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__PTRDIFF_T_TYPE__ |
__PTRDIFF_TYPE__ |
The cl2000 compiler defines the __PTRDIFF_T_TYPE__ macro symbol to indicate the equivalent base type associated with the ptrdiff_t type.
The c29clang compiler defines __PTRDIFF_TYPE__ to reflect the underlying type for the ptrdiff_t typedef.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__SIZE_T_TYPE__ |
__SIZE_TYPE__ |
The cl2000 compiler defines the __SIZE_T_TYPE__ macro symbol to indicate the equivalent base type associated with the size_t type.
The c29clang compiler defines __SIZE_TYPE__ to reflect the underlying type for the size_t typedef.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__TI_COMPILER_VERSION__ |
__ti_version__ |
The cl2000 compiler defines the __TI_COMPILER_VERSION__ macro symbol to a 7-9 digit integer, depending on if X has 1, 2, or 3 digits. The number does not contain a decimal. For example, version 3.2.1 is represented as 3002001. The leading zeros are dropped to prevent the number being interpreted as an octal.
The c29clang compiler defines __ti_version__ to encode the major, minor, and patch version number values associated with the current release, where:
<encoding> = <major> * 10000 <minor> * 100 <patch>For 3.2.1.LTS, for example, the value of <encoding> would be 30201.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__TI_EABI__ |
defined(__ELF__) |
Both the cl2000 and c29clang compilers support the generation of ELF object format code only. Consequently, the cl2000 __TI_EABI__ macro symbol is always defined when the cl2000 compiler is invoked.
c29clang does not support the __TI_EABI__ macro symbol, but it does support the __ELF__ macro symbol which is also supported by cl2000. Therefore, references to __TI_EABI__ in the C/C++ source can be safely replaced by __ELF__.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__TI_GNU_ATTRIBUTE_SUPPORT__ |
defined(__clang__) |
The cl2000 compiler defines the __TI_GNU_ATTRIBUTE_SUPPORT__ macro symbol to indicate that a C/C++ dialect mode where generic attributes is supported. c29clang does not support an analogous macro symbol, but generic attributes are supported by c29clang, nonetheless.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__TI_STRICT_ANSI_MODE__ |
__STRICT_ANSI__ |
The cl2000 compiler defines the __TI_STRICT_ANSI_MODE__ macro symbol to 1 if the cl2000 compiler is invoked with the --strict_ansi option. The cl2000 compiler defines __TI_STRICT_ANSI_MODE__ with a value of 0 by default to indicate that the compiler does not enforce strict conformance to the ANSI C standard.
The c29clang compiler defines the __STRICT_ANSI__ macro symbol if any of the --std=<spec> options are specified on the c29clang command-line (where spec indicates the identity of a C or C++ language standard).
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__TMS320C2000__ |
__C29__ |
The cl2000 compiler defines the __TMS320C2000__ macro symbol to true to indicated the application is compiled for the TI C28x architecture.
The c29clang compiler defines __C29__ to 1 if the application is compiled for a C29x target. See TI C29x-Specific Pre-Defined Macro Symbols for related macro symbols.
cl2000 Macro Symbol |
c29clang Equivalent |
|---|---|
__WCHAR_T_TYPE__ |
__WCHAR_TYPE__ |
The cl2000 compiler defines the __WCHAR_T_TYPE__ macro symbol to indicate the equivalent base type associated with the wchar_t type.
The c29clang compiler supports the analogous GCC __WCHAR_TYPE__ macro symbol to indicate the underlying type for the wchar_t typedef.
4.3.3. Pre-Defined Macro Symbols in cl2000 that are Not Applicable in c29clang¶
There are several pre-defined macro symbols that are supported by the cl2000 compiler that are either not applicable for c29clang or are simply not supported.
For example, the __TMS320C28XX__ pre-defined macro symbol indicates support for TI C28x, which does not apply for C29x applications.
cl2000 Macro Symbol |
Description / Comments |
|---|---|
|
The cl2000 |
|
The cl2000 |
|
The cl2000 |
|
The cl2000 |
|
The cl2000 |
|
The cl2000 |
|
The cl2000 |
4.3.4. Additional Pre-Defined Macro Symbols Supported in c29clang¶
The following pre-defined macro symbols are provided by the c29clang but not by the cl2000 compiler.
The c29clang compiler defines specific GNU macro symbols that are included in the table below. These macro symbols are not meant to distinguish GCC as a compiler; instead, they indicate code compatibility with GCC.
c29clang Macro Symbol |
Description / Comments |
|---|---|
|
An invocation of c29clang will always define the
|
|
The c29clang compiler would define the |
|
The |
|
The c29clang compiler defines the |
|
The c29clang compiler defines the |
|
The c29clang compiler defines the For example, if file |
|
The c29clang compiler defines |
|
If no optimization level is specified on the c29clang
command-line, then c29clang defines the |
|
If an optimization level is specified via the |
|
If the |
|
The c29clang compiler defines |
|
The c29clang compiler defined the |
|
The c29clang compiler defines |