04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Language Extensions<br />

3.4 Standard C language extensions<br />

The compiler supports numerous extensions to the ISO C99 standard, for example,<br />

function prototypes that override old-style non prototype definitions.<br />

These extensions are available if:<br />

• the source language is C99 and you are compiling in non strict mode<br />

• the source language is C90 and you are compiling in non strict mode.<br />

None of these extensions is available if:<br />

• the source language is C90 and the compiler is restricted to compiling strict C90<br />

using the --strict compiler option.<br />

• the source language is C99 and the compiler is restricted to compiling strict<br />

Standard C using the --strict compiler option.<br />

• the source language is C++.<br />

3.4.1 Constant expressions<br />

Extended constant expressions are supported in initializers. The following examples<br />

show the compiler behavior for the default, --strict_warnings, and --strict compiler<br />

modes.<br />

Example 1, assigning the address of variable<br />

Your code might contain constant expressions that assign the address of a variable at file<br />

scope, for example:<br />

int i;<br />

int j = (int)&i; /* but not allowed by ISO */<br />

When compiling for C, this produces the following behavior:<br />

• In default mode a warning is produced.<br />

• In --strict_warnings mode a warning is produced.<br />

• In --strict mode, an error is produced.<br />

Example 2, constant value initializers<br />

The compiler behavior when you have expressions that include constant values in C<br />

code is summarized in the following example:<br />

/* Std RVCT v3.1 */<br />

extern int const c = 10; /* ok ok */<br />

extern int const x = c + 10; /* error ext */<br />

3-10 Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. <strong>ARM</strong> DUI 0348C<br />

Non-Confidential,<br />

ID101213

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!