29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Language Extensions<br />

3.6.12 Structure, union, enum, and bitfield extensions<br />

The following structure, union, enum, and bitfield extensions are supported:<br />

• In C, the element type of a file-scope array can be an incomplete struct or union<br />

type. The element type must be completed before its size is needed, for example,<br />

if the array is subscripted. If the array is not extern, the element type must be<br />

completed by the end of the compilation.<br />

• The final semicolon preceding the closing brace } of a struct or union specifier<br />

can be omitted. A warning is issued.<br />

• An initializer expression that is a single value and is used to initialize an entire<br />

static array, struct, or union, does not have to be enclosed in braces. ISO C<br />

requires the braces.<br />

• An extension is supported to enable constructs similar to C++ anonymous unions,<br />

including the following:<br />

— not only anonymous unions but also anonymous structs are permitted. The<br />

members of anonymous structs are promoted to the scope of the containing<br />

struct and looked up like ordinary members.<br />

— they can be introduced into the containing struct by a typedef name. That<br />

is, they do not have to be declared directly, as is the case with true<br />

anonymous unions.<br />

— a tag can be declared but only in C mode.<br />

To enable support for anonymous structures and unions, you must use the<br />

anon_unions pragma.<br />

• An extra comma is permitted at the end of an enum list but a remark is issued.<br />

• enum tags can be incomplete. You can define the tag name and resolve it later, by<br />

specifying the brace-enclosed list.<br />

• The values of enumeration constants can be given by expressions that evaluate to<br />

unsigned quantities that fit in the unsigned int range but not in the int range. For<br />

example:<br />

/* When ints are 32 bits: */<br />

enum a { w = -2147483648 }; /* No error */<br />

enum b { x = 0x80000000 }; /* No error */<br />

enum c { y = 0x80000001 }; /* No error */<br />

enum d { z = 2147483649 }; /* Error */<br />

• Bit fields can have base types that are enum types or integral types besides int and<br />

unsigned int.<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 3-23<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!