NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Language Options in TI Compilers
Contents
Note that this page only applies starting with the following releases:
ISA | Version |
---|---|
ARM | 5.2.0 |
ARP32 | 1.1.0 |
C2000 | 6.3.0 |
C6000 | 7.6.0 |
MSP430 | 4.3.0 |
PRU | 1.1.0 |
See Production Compiler Releases for information on release availability.
Choosing a Language Option Set[edit]
The language mode in the TI compiler is a function of two options:
- The dialect, or what language standard to use
- The strictness, which is how the standard is interpreted.
Generally, the default mode should be sufficient for most applications, but in other cases, the application may have been written with a different language or behavior in mind.
The default mode is a nonstrict C89 mode. Extensions to this mode can be found here.
Choosing a Dialect[edit]
The first choice that should be made is what C or C++ dialect the program should be compiled under. A list of standard dialects TI supports can be found here.
- C Dialects
- C89 (--c89, default for C files)
- C99 (--c99)
- K&R C (--kr_compatible or -pk)
- C++ Dialects
- C++03 (--c++03, default for C++ files and C files under -fg)
- Embedded C++ (-pe)
If it is known under which standard an application or file was written, it's a good practice to use that dialect while compiling. However, if this is not known, then most often times the default will suffice. This is especially true for the default C mode under relaxed strictness, which incorporates many extensions from C99 into the C89 implementation.
For C++, the embedded C++ implementation is a subset of C++03 which disables many features for simplification and speed purposes. More information can be found at its Wikipedia entry. As it's just a subset, the default C++03 mode will compile any Embedded C++ application.
Choosing a Strictness Mode[edit]
The next choice is how strict the implementation should conform to the dialect chosen above.
- Strictness modes
- Relaxed (-pr, default)
- Strict (-ps)
Relaxed Mode[edit]
Two pages describe the relaxed mode:
- Under relaxed C modes, GCC Extensions are enabled in both C89 and C99 dialect modes
- In C89 mode, extensions originating as C99 features are enabled.
In addition, many code constructs which result in an error in strict conformance mode are instead accepted silently where possible, or result in a warning rather than an error.
Strict Mode[edit]
Under strict C modes, extensions are disabled barring one important feature, GCC-style attributes.
Keywords standard in C99 mode such as "inline" and "restrict" are disabled in C89 mode, but reserved replacements are provided in the form of double underlined versions, "__inline" and "__restrict". If a C89 program leverages these nonstandard keywords, adding a predefined macro mapping the keyword to its double underline twin (e.g. -Dinline=__inline) will allow the feature silently in strict mode.
The goal of strict mode is to allow for maximum portability to the TI compiler. If a program compiles in strict mode with any other compiler, it should compile with the TI compiler under strict mode.
Common Issues[edit]
A variety of issues may arise due to updating from an older version of the compiler to one which has the above language modes.