3.6.3. Anonymous classes, structures and unions

Anonymous classes, structures, and unions are supported as an extension. Anonymous structures and unions are supported in C and C++.

Anonymous unions are available by default in C++. However, you must specify the anon_unions pragma if you want to use:

An anonymous union can be introduced into a containing class by a typedef name. Unlike a true anonymous union, it does not have to be declared directly. For example:

typedef union
{
    int i, j;
} U;                 // U identifies a reusable anonymous union.

#pragma anon_unions

class A
{
    U;               // Okay -- references to A::i and A::j are allowed.
};

The extension also enables anonymous classes and anonymous structures, as long as they have no C++ features. For example, no static data members or member functions, no non public members, and no nested types (except anonymous classes, structures, or unions) are allowed in anonymous classes and anonymous structures. For example:

#pragma anon_unions

struct A
{
    struct
    {
        int i, j;
    };               // Okay -- references to A::i and A::j are allowed.
};

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential