GCC Extensions in TI Compilers

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Contents


Introduction

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 state of support for the GCC extensions in the TI C/C++ compilers.


Overview

The current (Sept 2010) GCC release is GCC 4.5. The definition and examples of the language extensions may be found at the GNU web site, in particular in the documentation for GCC 4.5.

Production TI compilers began including this support in 2006, and by 2007 it was available for all target architectures. An upgrade of the support began appearing in late 2010. The following table identifies the relevant compiler versions for the various targets. See Production Compiler Releases for information on release availability.


Target Initial
Release
Upgrade
Release
Compiler
User’s Guide
ARM 4.4.0 4.8.0 spnu151
C2000 5.0.0 6.0.0 spru514
C5500 4.0.0 4.4.0 spru281
C6000 6.1.0 7.2.0 spru187
MSP430 2.0.0 4.0.0 slau132


The Optimizing C/C++ Compiler User’s Guide for your target has a section entitled GNU C Compiler Extensions which lists the supported extensions. However, depending on the publication date of the manual and the compiler release date, the manual may not reflect the exact level of support available in your compiler.


Enabling GCC Language Extensions

The GCC language extensions are available when compiling in “Relaxed ANSI” mode (selected by the --relaxed_ansi option) or when the --gcc option is used.

Most extensions (when supported) are available in both C and C++, but not all are specified by GCC as being included in C++. Prior to the Upgrade Release the GCC extensions were not supported for C++ by the TI compilers.

 Prior to the Upgrade Release the GCC extensions are not included in Relaxed ANSI mode; --gcc must be used.


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 When column
-- Not supported
A Initial Release
B Upgrade Release


Feature When Description
Statement Exprs A Putting statements and declarations inside expressions
Local Labels A 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 A Giving a name to the type of some expression
Typeof A typeof: referring to the type of an expression.
Generalized Lvalues A Using '?:', ',' and casts in lvalues.
Conditionals A Omitting the middle operand of a '?:' expression.
Long Long A 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 A Zero-length arrays.
Variable Length -- Arrays whose length is computed at run time. For alloca(), see GNU alloca in TI Compilers
Empty Structures A Structures with no members.
Variadic Macros A Macros with a variable number of arguments.
Escaped Newlines -- Slightly looser rules for escaped newlines.
Multi-line Strings A String literals with embedded newlines
Subscripting A Any array can be subscripted, even if not an lvalue.
Pointer Arith B Arithmetic on void-pointers and function pointers.
Initializers A Non-constant initializers.
Compound Literals A Compound literals give structures, unions or arrays as values.
Designated Inits B Labeling elements of initializers.
Cast to Union A Casting to union type from any member of the union.
Case Ranges A 'case 1 ... 9' and such.
Mixed Declarations A Mixing declarations and code.
Function Attributes A Declaring that functions have no side effects, or that they can never return. (See details below)
Attribute Syntax A Formal syntax for attributes.
Function Prototypes A Prototype declarations and old-style definitions.
C++ Comments A C++ comments are recognized.
Dollar Signs A Dollar sign is allowed in identifiers.
Character Escapes A '\e' stands for the character <ESC>.
Variable Attributes A Specifying attributes of variables. (See details below)
Type Attributes A Specifying attributes of types. (See details below)
Alignment A Inquiring about the alignment of a type or variable. (__alignof__)
Inline A Defining inline functions (as fast as macros).
Extended Asm -- Assembler instructions with C expressions as operands.
Constraints -- Constraints for asm operands
Asm Labels A Specifying the assembler name to use for a C symbol.
Explicit Reg Vars -- Defining variables residing in specified registers.
Alternate Keywords A __const__, __asm__, etc., for header files. (also __extension__)
Incomplete Enums A Define an enum tag without specifying its values
Function Names A Printable strings which are the name of the current function (__FUNCTION__, etc)
Return Address A 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 A Other built-in functions. (See details below)
Target Builtins A 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 A Unnamed struct/union fields within structs/unions.
Thread-Local -- Per-thread variables.
Binary constants -- Binary constants using the '0b' prefix.


Notes

Attributes

Function Attributes

Function attribute definitions and examples at the GNU web site.


Available in Initial Release

deprecated, section, unused, visibility (C60 EABI only)
Added in Upgrade Release

always_inline, const, constructor, format, format_arg, malloc, noinline, noreturn/volatile,
pure, used, warn_unused_result, weak (EABI only)

Notes


Variable Attributes

Variable attribute definitions and examples at the GNU web site.


Available in Initial Release

deprecated, section, unused
Added in Upgrade Release

aligned, mode, packed, transparent_union, used, weak (EABI only)

Notes


Type Attributes

Type attribute definitions and examples at the GNU web site.


Available in Initial Release

packed (enum), unused, visibility (C60 EABI only)
Added in Upgrade Release

aligned, deprecated, packed (struct/union), transparent_union

Notes


Builtin Functions

Information about builtin functions at the GNU web site.


Available in Initial Release

__builtin_constant_p, __builtin_expect, __builtin_frame_address, __builtin_return_address
Added in Upgrade Release

__builtin_abs, __builtin_fabs, __builtin_fabsf, __builtin_labs, __builtin_llabs, __builtin_memcpy,
__builtin_sqrt, __builtin_sqrtf

Notes

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox