TI Compilers and Industry Standards

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   
There are security restrictions on this page

Contents

C and C++ standards

All TI compilers support:

TI performs extensive validation tests to ensure that the compiler generates correct ANSI C (C89) and C++ (1998) code.

C standard variants

See this Wikipedia page for a history of C variants.

The original ANSI standard is called "C89". This was adopted by ISO with minor revisions (mostly section number changes), and the ISO version is called "C90".

The so-called "C95" (actually C89 + Normative Addendum 1) adds just a few things to C89: iso646.h, digraphs, and a bunch of wide- and extended-character functions.

The C99 revision of the C standard adds many new features. See the Wikipedia entry.

Only C89 is officially supported, but we do provide some of these features as language extensions. Examples are the restrict keyword and the header file stdint.h from C99, and iso646.h from C95.

C++ standard variants

We do not support: C++ 2003, C++ TR1.

See also Overview of C++ Support in TI Compilers

Variations from the C standard

There are a few points for which the TI compilers don't conform to the requirements for a hosted implementation. The TI implementation is not technically a hosted implementation, it is a freestanding implementation, for which the standard allows the implementation some leeway. However, the implementation is very close to meeting the requirements of a hosted implementation. The exceptions are shown below. C99 sections are cited because the C99 standard is easier to obtain and is usually substantively the same as C89.

This section does not list features which are temporarily broken due to bugs.

Misunderstandings about TI C

There are quite a few things that TI compilers do a little bit differently than hosted compilers which cause confusion. The following things are legal in terms of the C standard, but are frequently mistaken for standards violations:

Having a 16-bit char can lead to unintuitive results like sizeof(long)==2 and sizeof(int)==1, but this is perfectly legal, and on these targets, is the best choice for type sizes based on the CPU arithmetic the targets can support.
int a = 300;
int b = 200;
int c = a * b; /* oops, this overflows on 16-bit targets */
long d = a * b; /* oops, this overflows, too */
long e = (long)a * (long)b; /* correct version */

Misunderstandings about C in general

For many more items like these, see comp.lang.c Frequently Asked Questions

FILE *binary_data = fopen("data", "rb"); 
char c;
while ((c = getc(binary_data)) != EOF) /* oops, 0xff in "data" will break this code */
    do_something();

Other industry standards

IEEE 754

The currently supported TI compilers use IEEE 754 format to store 32- and 64-bit floating point numbers, but do not implement every part of IEEE 754. The C89 standard does not even require IEEE format, and for C99, full IEEE 754 support (Inf, NaN, denormals) is optional.

See the Wikipedia page for more information about IEEE 754.

IEC61508, TÜV, MISRA-C

Additional industry specific tests such as IEC61508 safety tests, automotive TÜV safety tests, and MISRA-C are the responsibility of the user.

Leave a Comment

Comments

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox