NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

GCC Extensions in TI Compilers

From Texas Instruments Wiki
Jump to: navigation, search


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 4.3.

At the time of writing (April 2014), the current GCC release is GCC 4.9.

The following table shows when the current GCC extension support became available. See Production Compiler Releases for information on release availability.

Target Release Compiler
User’s Guide
ARM 4.8.0 spnu151
ARP32 1.0.0 spruh24 (no link)
C2000 6.0.0 spru514
C5500 4.4.0 spru281
C6000 7.2.0 spru187
MSP430 4.0.0 slau132
PRU 1.0.0 N/A

For information on older releases of the TI compiler, see GCC Extensions in TI Compilers (06Q1-10Q4).

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

In 2013, the default behavior of the compiler changed. The default is now relaxed mode, and GCC extensions are enabled by default. Starting with the following releases, The GCC language extensions are available by default. They are disabled in strict ANSI mode.

Target Release
ARM 5.2.0
ARP32 1.1.0
C2000 6.4.0
C6000 7.5.0
MSP430 4.3.0
PRU 1.1.0

Before 2013, the GCC language extensions are available when compiling in relaxed ANSI mode or in GCC mode (when --gcc option is used).

C vs C++

The GCC extensions supported by the TI compiler are available in both C and C++, even though not all are specified by GCC as being active in C++ mode.

Language Features

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.

Code Availability
Key to Supported column
-- Feature is not supported
yes Feature is supported
Feature Supported Description
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 '?:', ',' and casts in lvalues.
Conditionals yes Omitting the middle operand of a '?:' expression.
Long Long yes Double-word integers---long long int.
Complex -- Data types for complex numbers.
Floating Types -- Additional floating types.
Decimal Float -- Decimal floating types.
Hex Floats -- Hexadecimal floating-point constants.
Fixed-Point -- Fixed-point types.
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 yes* Arithmetic on void-pointers and function pointers.
Initializers yes Non-constant initializers.
Compound Literals yes Compound literals give structures, unions or arrays as values.
Designated Inits yes* Labeling elements of initializers.
Cast to Union yes Casting to union type from any member of the union.
Case Ranges yes 'case 1 ... 9' and such.
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.
Character Escapes yes '\e' stands for the character <ESC>.
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. (__alignof__)
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.
Alternate Keywords yes __const__, __asm__, etc., for header files. (also __extension__)
Incomplete Enums yes Define an enum tag without specifying its values
Function Names yes Printable strings which are the name of the current function (__FUNCTION__, etc)
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 offsetof.
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.
Thread-Local -- Per-thread variables.
Binary constants -- Binary constants using the '0b' prefix.


  • * = Support for this feature is new in this release.
  • 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.
  • When the long long type 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.
  • Not all function attributes, variable attributes, type attributes, and builtin functions are supported. See the following sections for details on these features.


Function Attributes

Function attribute definitions and examples at the GNU web site.

Supported Function Attributes

  • always_inline *
  • const *
  • constructor *
  • deprecated
  • format *
  • format_arg *
  • malloc *
  • noinline *
  • noreturn/volatile *
  • pure *
  • section
  • unused
  • used *
  • visibility (C60 EABI dynamic shared objects only)
  • warn_unused_result *
  • weak (EABI only) *


  • * = Support for this attribute is new in this release.
  • The format attribute is applied to the declarations of printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf, scanf, fscanf and sscanf in stdio.h. This means that when GCC extensions are available the data arguments of these functions will be type checked against the format specifiers in the format string argument and warnings issued when there is a mismatch. These warnings can be suppressed in the usual ways if they are not desired.
  • The malloc attribute is applied to the declarations of malloc, calloc, realloc and memalign in stdlib.h

Variable Attributes

Variable attribute definitions and examples at the GNU web site.

Supported Variable Attributes

  • aligned *
  • deprecated
  • mode *
  • packed *
  • section
  • transparent_union *
  • unused
  • used *
  • weak (EABI only) *


  • * = Support for this attribute is new in this release.
  • See the notes about packed (struct/union) in the Type Attributes section.

Type Attributes

Type attribute definitions and examples at the GNU web site.

Supported Type Attributes

  • aligned *
  • deprecated *
  • packed (enum)
  • packed (struct/union) *
  • transparent_union *
  • unused
  • visibility (C60 EABI dynamic shared objects only)


  • * = Support for this attribute is new in this release.
  • The packed (struct/union) attribute is NOT available for C5500 or C2000.
  • The packed (struct/union) attribute is available for C6000 only for architectures which support unaligned access (C64x, C64x+, etc.).
  • The packed (struct/union) attribute is available on ARM only for architectures which support unaligned access (Cortex) and when the --unaligned_access=on option is in effect. (Note: that --unaligned_access=on by default for architectures which support unaligned access.)
  • For ARM, the packed (struct/union) attribute may not be used, directly or indirectly, on a member of a struct or union of type long long, unsigned long long, double, or long double.
  • The 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. Newly in this release, the packed (struct/union) attribute may not be used on a bit-field.

Builtin Functions

Information about builtin functions at the GNU web site.

Supported Builtin Functions

  • __builtin_constant_p
  • __builtin_expect
  • __builtin_frame_address
  • __builtin_return_address
  • __builtin_abs
  • __builtin_fabs
  • __builtin_fabsf
  • __builtin_labs
  • __builtin_llabs
  • __builtin_memcpy
  • __builtin_sqrt
  • __builtin_sqrtf


  • The function __builtin_expect does not currently provide optimization based on this construct.
  • The functions __builtin_frame_address and __builtin_return_address return zero for all arguments except a constant zero for C6000 and ARM targets.
  • The function __builtin_llabs is available only on targets that support the type long long.
  • The functions __builtin_sqrt and __builtin_sqrtf are available only for ARM with VFP hardware.