[previous] 1043 [next] [E] Defining an anonymous union object. This is a language extension.
Language extensions

This is a declaration of an anonymous union. Anonymous unions are a feature of C++ but are not supported in ISO:C Standard.

An anonymous union is an unnamed object of an unnamed union type. The names of the members of an anonymous union must be distinct from the names of any other ordinary identifiers in the scope in which the anonymous union is declared. The members of an anonymous union are treated as ordinary objects within the scope in which the anonymous union is declared and can be addressed as ordinary objects.

For example:


/*PRQA S 750,2017,3132,3227,3408 ++*/

union                                                                   /* Message 1043 */
{
    unsigned short us;
    unsigned char  uc[2];
};

extern void foo(unsigned short usx)
{
    us = usx;
}


MISRA-C:2004 Rules applicable to message 1043:

Rule  1.1  (Required) All code shall conform to ISO/IEC 9899:1990 C programming language, ISO 9899, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2: 1996192


QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents