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.

GCC Extensions in TI Compilers (06Q1-10Q4)

From Texas Instruments Wiki
Jump to: navigation, search

Introduction[edit]

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.

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

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[edit]

The GCC extensions are only available in GCC mode; you must use the option --gcc.

C vs C++[edit]

The GCC extensions supported by the TI compiler are only available in C.

Language Features[edit]

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

Notes

  • 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 long type is not supported.
  • 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.
  • 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.

Attributes[edit]

Function Attributes[edit]

Function attribute definitions and examples at the GNU web site.

Supported Function Attributes

  • deprecated
  • section
  • unused
  • visibility (C60 EABI only)

Variable Attributes[edit]

Variable attribute definitions and examples at the GNU web site.

Supported Variable Attributes

  • deprecated
  • section
  • unused

Type Attributes[edit]

Type attribute definitions and examples at the GNU web site.

Supported Type Attributes

  • packed (enum types only)
  • unused
  • visibility (C60 EABI only)

Notes

  • 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, but may not be used, directly or indirectly, on a bit-field.

Builtin Functions[edit]

Information about builtin functions at the GNU web site.

Supported Builtin Functions

  • __builtin_constant_p
  • __builtin_expect
  • __builtin_frame_address
  • __builtin_return_address

Notes

  • The function __builtin_constant_p is not treated as compile-time constant.
  • The function __builtin_expect does not provide optimization based on this construct.
  • The functions __builtin_frame_address and __builtin_return_address always return zero.
  • 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.
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article GCC Extensions in TI Compilers (06Q1-10Q4) here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article GCC Extensions in TI Compilers (06Q1-10Q4) here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article GCC Extensions in TI Compilers (06Q1-10Q4) here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity