Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.
GCC Extensions in TI Compilers (06Q1-10Q4)
The GNU Compiler Collection (GCC) supports many language features not found in the ANSI/ISO standards for C and C++. The GCC compilers (gcc and g++) are widely used, particularly in open source applications. In order to allow users to compile code developed using the GCC tools, TI compilers can accept some GCC language extensions. This article describes the current state of support for the GCC extensions in the TI C/C++ compilers.
The TI compiler supports some of the extensions supported by GCC version 3.0.
At the time of writing (Sept. 2010), the current GCC release is GCC 4.5.
The following table shows when GCC extension support became available. See Production Compiler Releases for information on release availability.
For information on the GCC extension support of the latest releases of the TI compiler, see GCC Extensions in TI Compilers.
Older TI compilers do not support a GCC mode, and thus do not directly support GCC extensions. However, some C99 extensions in C89 mode are similar.
TI does not document the use or purpose of GCC extensions. The definition and examples of the language extensions may be found at the GNU documentation web site. The Optimizing C/C++ Compiler User’s Guide for your target has a section entitled GNU C Compiler Extensions which lists the supported extensions. As the support for GCC extensions has changed over time, make sure you refer to the correct version of the user's guide.
Enabling GCC Language Extensions
The GCC extensions are only available in GCC mode; you must use the option --gcc.
C vs C++
The GCC extensions supported by the TI compiler are only available in C.
The following table of features is based on the list of extensions given at the GNU web site (GCC 4.5). Each feature name is a link to the corresponding GNU definition of the feature.
|--||Feature is not supported|
|yes||Feature is supported|
|Statement Exprs||yes||Putting statements and declarations inside expressions|
|Local Labels||yes||Labels local to a block|
|Labels as Values||--||Getting pointers to labels, and computed gotos|
|Nested Functions||--||As in Algol and Pascal, lexical scoping of functions|
|Constructing Calls||--||Dispatching a call to another function.|
|Naming Types||yes||Giving a name to the type of some expression|
|Typeof||yes||typeof: referring to the type of an expression.|
|Generalized Lvalues||yes||Using '|
|Conditionals||yes||Omitting the middle operand of a '|
|Long Long||yes||Double-word integers---|
|Complex||--||Data types for complex numbers.|
|Floating Types||--||Additional floating types.|
|Decimal Float||--||Decimal floating types.|
|Hex Floats||--||Hexadecimal floating-point constants.|
|Named Address Spaces||--||Named address spaces.|
|Zero Length||yes||Zero-length arrays.|
|Variable Length||--||Arrays whose length is computed at run time. For alloca(), see GNU alloca in TI Compilers|
|Empty Structures||yes||Structures with no members.|
|Variadic Macros||yes||Macros with a variable number of arguments.|
|Escaped Newlines||--||Slightly looser rules for escaped newlines.|
|Multi-line Strings||yes||String literals with embedded newlines|
|Subscripting||yes||Any array can be subscripted, even if not an lvalue.|
|Pointer Arith||--||Arithmetic on void-pointers and function pointers.|
|Compound Literals||yes||Compound literals give structures, unions or arrays as values.|
|Designated Inits||--||Labeling elements of initializers.|
|Cast to Union||yes||Casting to union type from any member of the union.|
|Mixed Declarations||yes||Mixing declarations and code.|
|Function Attributes||yes||Declaring that functions have no side effects, or that they can never return. (See details below)|
|Attribute Syntax||yes||Formal syntax for attributes.|
|Function Prototypes||yes||Prototype declarations and old-style definitions.|
|C++ Comments||yes||C++ comments are recognized.|
|Dollar Signs||yes||Dollar sign is allowed in identifiers.|
|Variable Attributes||yes||Specifying attributes of variables. (See details below)|
|Type Attributes||yes||Specifying attributes of types. (See details below)|
|Alignment||yes||Inquiring about the alignment of a type or variable. (|
|Inline||yes||Defining inline functions (as fast as macros).|
|Extended Asm||--||Assembler instructions with C expressions as operands.|
|Constraints||--||Constraints for asm operands|
|Asm Labels||yes||Specifying the assembler name to use for a C symbol.|
|Explicit Reg Vars||--||Defining variables residing in specified registers.|
|Incomplete Enums||yes||Define an enum tag without specifying its values|
|Function Names||yes||Printable strings which are the name of the current function (|
|Return Address||yes||Getting the return or frame address of a function.|
|Vector Extensions||--||Using vector instructions through built-in functions.|
|Offsetof||--||Special syntax for implementing |
|Atomic Builtins||--||Built-in functions for atomic memory access.|
|Object Size Checking||--||Built-in functions for limited buffer overflow checking.|
|Other Builtins||yes||Other built-in functions. (See details below)|
|Target Builtins||yes||Built-in functions specific to particular targets.|
|Target Format Checks||n/a||Format checks specific to particular targets. (Solaris-only)|
|Pragmas||--||Pragmas accepted by GCC.|
|Unnamed Fields||yes||Unnamed struct/union fields within structs/unions.|
|Binary constants||--||Binary constants using the '|
- Statement Expressions are not currently available in C++.
- The Naming Types feature was dropped after GCC 3.1, but is still supported in the TI compiler.
- For MSP430 the
long longtype is not supported.
- When the
long longtype is supported it is always available even in strict ANSI mode.
- The Multi-line Strings feature was dropped after GCC 3.2, but is still supported in the TI compiler.
- The Desiginated Inits feature is supported only for struct types.
- The following features were not rejected even though they were not supported by the compiler: Labels as Values, Hex Floats, Pointer Arith, Extended Asm, Constraints, and Explicit Reg Vars.
- Not all function attributes, variable attributes, type attributes, and builtin functions are supported. See the following sections for details on these features.
Function attribute definitions and examples at the GNU web site.
Supported Function Attributes
- visibility (C60 EABI only)
Variable attribute definitions and examples at the GNU web site.
Supported Variable Attributes
Type attribute definitions and examples at the GNU web site.
Supported Type Attributes
- packed (enum types only)
- visibility (C60 EABI only)
packed(struct/union) attribute is also available for ARM Cortex M3 starting with version 4.6.1 and for Cortex R4 and A8 devices starting with version 4.7.0, but may not be used, directly or indirectly, on a bit-field.
Information about builtin functions at the GNU web site.
Supported Builtin Functions
- The function
__builtin_constant_pis not treated as compile-time constant.
- The function
__builtin_expectdoes not provide optimization based on this construct.
- The functions
__builtin_return_addressalways return zero.
- The function
__builtin_llabsis available only on targets that support the type
- The functions
__builtin_sqrtfare available only for ARM with VFP hardware.