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
__COUNTER__
References to the __COUNTER__ macro symbol expand to an
integer value starting from 0. This symbol can be used
in conjunction with a “##” operator in C/C++ source code
to create unique symbol names.
__cplusplus
The __cplusplus symbol is defined if the cl2000 or
c29clang compiler is invoked to process a C++ source
file. If the source file in question is an obvious C++
source file with a .cpp extension, then both compilers
define __cplusplus when processing such a file. The
user can also force __cplusplus to be defined via the
cl2000 -fg option or the c29clang -x c++ option. These
instruct the compiler to process a source file, whether
it is a C++ or C file, as a C++ file.
__DATE__
References to the __DATE__ macro symbol expand to a
string representing the date on which the compiler was
invoked. The date is displayed in the form: mmm dd yyyy.
__ELF__
The __ELF__ macro symbol is defined by both the cl2000 and
c29clang compilers, since both generate ELF object format.
__FILE__
References to the __FILE__ macro symbol expand to a string
representation of the name of the source file being compiled.
_INLINE
Defined if some level of optimization is specified when the compiler is invoked.
The cl2000 compiler allows C/C++ source code to undefine the
_INLINE symbol to disable some optimization while processing C/C++ source.
The c29clang compiler does not support turning off inlining by
undefining macros. The c29clang compiler additionally supports the
the __GNUC_GNU_INLINE__, __GNUC_STDC_INLINE__, and __NO_INLINE__ macros, so that
code can test to see what type of inlining is enabled.
__LINE__
References to the __LINE__ macro symbol expand to an
integer constant indicating the current source line in
the source file. The value of the integer constant
depends on which source line the macro symbol is referenced.
__STDC__
Both the cl2000 and c29clang compilers define the
__STDC__ macro symbol to indicate compliance with the
ISO C standard. Please refer to the TI C28x Optimizing C/C++
Compiler User’s Guide for exceptions to ISO C compliance
that apply to the cl2000 compiler. Exceptions to ISO C
compliance in the c29clang compiler can be found in
the TI C29x Clang Compiler User Guide.
__STDC_HOSTED__
The __STDC_HOSTED__ macro symbol is always defined to 1 to indicate that the
target is a hosted environment, meaning the standard C library is available.
__STDC_NO_THREADS__
The __STDC_NO_THREADS__ macro symbol is always defined to 1 to indicate the
implementation does not support optional standard threads.
__STDC_VERSION__
The __STDC_VERSION__ macro symbol expands to an integer
constant that indicates the ISO C standard that the
compiler conforms to.
__TIME__
References to the __TIME__ macro symbol expand to a
string representation of the time at which the compiler
is invoked. The time is displayed in the form: hh:mm:ss.
__TIMESTAMP__
References to the __TIMESTAMP__ macro symbol expand to a
string representation of the date and time at which the
compiler was invoked. The date and time are displayed in
the form: dow mmm dd hh:mm:ss yyyy (dow is “day of the week”).
__VERSION__
The __VERSION__ macro symbol provides information about
which version of the C/C++ parser is used by the compiler.
The cl2000 compiler uses some version of the EDG
gcc-compatible parser, whereas the c29clang compiler’s
parser uses a version of the LLVM and Clang source base.
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 __TI_EABI__, 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 C29 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 |
---|---|
__TMS320C28XX__ |
The cl2000 __TMS320C28XX__ macro symbol is not applicable since c29clang does not support the TI C28x architecture. |
__TMS320C28XX_CLA__ __TMS320C28XX_CLA0__ __TMS320C28XX_CLA1__ __TMS320C28XX_CLA2__ |
The cl2000 __TMS320C28XX_CLAn__ macro symbols are not applicable since c29clang does not support the Control Law Accelerator (CLA) or the CLA compiler. |
__TMS320C28XX_FPU32__ __TMS320C28XX_FPU64__ |
The cl2000 __TMS320C28XX_FPUnn__ macro symbols are not applicable since c29clang does not support the Floating Point Unit (FPU). |
__TMS320C28XX_IDIV__ |
The cl2000 __TMS320C28XX_IDIV__ macro symbol are not applicable since c29clang does not support the IDIV intrinsics. |
__TMS320C28XX_TMU__ __TMS320C28XX_TMU0__ __TMS320C28XX_TMU1__ |
The cl2000 __TMS320C28XX_TMUn__ macro symbols are not applicable since c29clang does not support the Trigonometric Math Unit (TMU). |
__TMS320C28XX_VCU0__ __TMS320C28XX_VCU2__ __TMS320C28XX_VCRC__ |
The cl2000 __TMS320C28XX_VCUn__ macro symbols are not applicable since c29clang does not support the Viterbi, Complex Math and CRC Unit (VCU). |
__TI_STRICT_FP_MODE__ |
The cl2000 __TI_STRICT_FP_MODE__ macro symbol is defined to 1 by default to indicate that the compiler is to be strict about floating-point math (adherence to the IEEE-754 standard for floating-point arithmetic). This reflects the default argument for the --fp_mode option (i.e. --fp_mode=strict). To instruct the compiler to be more relaxed about floating-point math, the --fp_mode=relaxed option can be specified, which will cause __TI_STRICT_FP_MODE__ to be defined with a value of 0. |
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 |
|
---|---|
__clang__ |
An invocation of c29clang will always define the __clang__ macro symbol. |
__EXCEPTIONS |
The c29clang compiler would define the __EXCEPTIONS macro symbol if -fexceptions were specified when compiling a C++ source file. However, exceptions are not currently supported by the c29clang compiler. |
__GNUC__ |
The __GNUC__ macro symbol indicates that the compiler’s C pre-processor is compatible with a major version of the GNU C pre-processor. The c29clang compiler’s C pre-processor is compatible with version 3 of the GNU C pre-processor. |
__GNUC_GNU_INLINE__ |
The c29clang compiler defines the __GNUC_GNU_INLINE__ macro symbol if optimization is turned on and functions declared inline are handled in GCC’s traditional gnu90 mode. Object files will contain externally visible definitions of all functions declared inline without extern or static. They will not contain any definitions of any functions declared extern inline. |
__GNUC_STDC_INLINE__ |
The c29clang compiler defines the __GNUC_STDC_INLINE__ macro symbol if optimization is turned on and functions that are declared inline are handled according to the ISO C99 (or later) C language standard. Object files will contain externally visible definitions of all functions declared extern inline. They will not contain definitions of any functions declared inline without extern. |
__INCLUDE_LEVEL__ |
The c29clang compiler defines the __INCLUDE_LEVEL__ macro symbol as an integer constant indicating the current include level. For example, if file f1.c includes f2.h and f2.h contains a reference to __INCLUDE_LEVEL__, then that reference to __INCLUDE_LEVEL__ would evaluate to 1. |
__INTMAX_TYPE__ |
The c29clang compiler defines __INTMAX_TYPE__ to reflect the underlying type for the intmax_t typedef. |
__NO_INLINE__ |
If no optimization level is specified on the c29clang command-line, then c29clang defines the __NO_INLINE__ macro symbol to indicate that compilation mode. |
__OPTIMIZE__ |
If an optimization level is specified via the -O option on the c29clang command-line, then c29clang defines the __OPTIMIZE__ macro symbol to indicate that optimization is enabled for the current compilation. |
__OPTIMIZE_SIZE__ |
If the -Os or -Oz option is specified on the c29clang command-line, then c29clang defines the __OPTIMIZE_SIZE__ macro symbol to indicate that optimizations that do not typically increase code size and optimizations that are designed to reduce code size are enabled for the current compilation. |
__UINTMAX_TYPE__ |
The c29clang compiler defines __UINTMAX_TYPE__ to reflect the underlying type for the uintmax_t typedef. |
__WCHAR_UNSIGNED__ |
The c29clang compiler defined the __WCHAR_UNSIGNED__ macro symbol to indicate that the wchar_t type assumed when compiling a C++ source file is unsigned. |
__WINT_TYPE__ |
The c29clang compiler defines __WINT_TYPE__ to reflect the underlying type for the wint_t typedef. |