Keil Logo Arm Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Conventions and Feedback Introduction Compiler Command-line Options Language Extensions Preprocessor extensions #assert #include_next #unassert #warning C99 language features available in C90 // comments Subscripting struct Flexible array members C99 language features available in C++ and C90 Variadic macros long long restrict Hexadecimal floats Standard C language extensions Constant expressions Array and pointer extensions Block scope function declarations Dollar signs in identifiers Top-level declarations Benign redeclarations External entities Function prototypes Standard C++ language extensions ? operator Declaration of a class member friend Read/write constants Scalar type constants Specialization of nonmember function templates Type conversions Standard C and Standard C++ language extensions Address of a register variable Arguments to functions Anonymous classes, structures and unions Assembler labels Empty declaration Hexadecimal floating-point constants Incomplete enums Integral type extensions Label definitions Long float Nonstatic local variables Structure, union, enum, and bitfield extensions Compiler-specific Features C and C++ Implementation Details Semihosting ARMv6 SIMD Instruction Intrinsics Via File Syntax Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Compiler Reference Guide

Anonymous classes, structures and unions

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:

  • anonymous unions and structures in C

  • anonymous classes and structures in C++.

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 nonpublic 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 i and j 
};                   // through class A are allowed.

int foo(int m)
{
    A a;
     a.i = m;
     return a.i;
}
Copyright © 2007-2008, 2011-2012 ARM. All rights reserved.ARM DUI 0376D
Non-ConfidentialID062912

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.