Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler Features Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR 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 GNU extensions to the C and C++ languages Compiler-specific Features C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Structure, union, enum, and bitfield extensions

8.44 Structure, union, enum, and bitfield extensions

The following structure, union, enum, and bitfield extensions are supported.

  • In C, the element type of a file-scope array can be an incomplete struct or union type. The element type must be completed before its size is required, for example, if the array is subscripted. If the array is not extern, the element type must be completed by the end of the compilation.
  • The final semicolon preceding the closing brace } of a struct or union specifier can be omitted. A warning is issued.
  • An initializer expression that is a single value and initializes an entire static array, struct, or union, does not have to be enclosed in braces. ISO C requires the braces.
  • An extension is supported to enable constructs similar to C++ anonymous unions, including the following:
    • Not only anonymous unions but also anonymous structs are permitted. The members of anonymous structs are promoted to the scope of the containing struct and looked up like ordinary members.
    • They can be introduced into the containing struct by a typedef name. That is, they do not have to be declared directly, as is the case with true anonymous unions.
    • A tag can be declared but only in C mode.
    To enable support for anonymous structures and unions, you must use the anon_unions pragma.
  • An extra comma is permitted at the end of an enum list but a remark is issued.
  • enum tags can be incomplete. You can define the tag name and resolve it later, by specifying the brace-enclosed list.
  • The values of enumeration constants can be given by expressions that evaluate to unsigned quantities that fit in the unsigned int range but not in the int range. For example:
    /* When ints are 32 bits: */
    enum a { w = -2147483648 };  /* No error */
    enum b { x = 0x80000000 };   /* No error */
    enum c { y = 0x80000001 };   /* No error */
    enum d { z = 2147483649 };   /* Error */
    
  • In C, oversized bitfields are supported. Oversized bitfields are part of standard C++. The semantics of oversized bitfields in ARM C is the same as for standard C++.
    An oversized bitfield is a field in a structure which has the form basetype v:N or basetype:N where the size in bits of basetype is less than N. For example, in char a:16; type char has 8 bits while the bitfield has 16 bits. The extra bits are treated as padding.
  • Bitfields can have base types that are enum types or integral types besides int and unsigned int.
Related reference
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  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.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.