[previous] 0633 [next] [E] Empty structures and unions are a language extension.
Language extensions REFERENCE - ISO:C90-6.5.2.1 Structure and Union Specifiers - Syntax

A structure or union type is being defined with no members. This is an extension to the C language and is only supported by certain compilers. The size of an empty structure or union is assumed to be zero.

Empty structures are an integral part of the C++ language, but the C++ Language Standard says they have size 1.

A structure or union with no members is considered to be a complete type and should not be confused with declarations of incomplete type which are allowed in standard C.

For example:


/*PRQA S 553,750,759,2017,2213,3210,3313,3447 ++*/

extern struct STA { } a;    /* Message 0633 */
extern union  UNB { } b;    /* Message 0633 */
extern struct STC * pc;     /* No message - pointer to incomplete struct */
extern union  UND * pd;     /* No message - pointer to incomplete union  */

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents