[previous] 1025 [next] [C] Using '__alignof__' on bit-fields is illegal.
Constraint violations

This is a constraint error

The operand of the __alignof__ operator cannot be a bit-field.

'__alignof__' is not part of the standard C language. It is supported by the GCC compiler as an that returns the alignment requirements in bytes of its operand.

For example:


/*PRQA S 1022,1257,2017,3131,3199,3203,3408,3447,3621 ++*/

struct test
{
    unsigned int b:3;
};
extern struct test test1;

extern void foo(void)
{
    int a;

    a = __alignof__(test1.b);           /* Message 1025 */
}


MISRA-C:2004 Rules applicable to message 1025:

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


See also:

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