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.3 Anonymous classes, structures and unions<br />

Anonymous classes, structures, and unions are supported as an extension. Anonymous<br />

structures and unions are supported in C and C++.<br />

Anonymous unions are available by default in C++. However, you must specify the<br />

anon_unions pragma if you want to use:<br />

• anonymous unions and structures in C<br />

• anonymous classes and structures in C++.<br />

An anonymous union can be introduced into a containing class by a typedef name.<br />

Unlike a true anonymous union, it does not have to be declared directly. For example:<br />

typedef union<br />

{<br />

int i, j;<br />

} U; // U identifies a reusable anonymous union.<br />

#pragma anon_unions<br />

class A<br />

{<br />

U; // Okay -- references to A::i and A::j are allowed.<br />

};<br />

The extension also enables anonymous classes and anonymous structures, as long as<br />

they have no C++ features. For example, no static data members or member functions,<br />

no non public members, and no nested types (except anonymous classes, structures, or<br />

unions) are allowed in anonymous classes and anonymous structures. For example:<br />

#pragma anon_unions<br />

struct A<br />

{<br />

struct<br />

{<br />

int i, j;<br />

}; // Okay -- references to A::i and A::j are allowed.<br />

};<br />

See also<br />

• Unnamed fields on page 3-31<br />

• #pragma [no_]anon_unions on page 4-49.<br />

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

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!