![]() |
![]() |
0660 | ![]() |
||||
![]() | |||||||
| Language extensions | |||||||
Declaring an unnamed member (other than a bit-field) in a struct or union is a language extension. Structs and unions declared without a name are sometimes described as "anonymous". Various mechanisms exist to access their members. An example is demonstrated in the code below and is identified with message 0662. For example:
/*PRQA S 553,750,1314,2017,3132,3199,3203,3211,3408,3447 ++*/
struct A1
{
unsigned int ax;
struct A2
{
unsigned char ay;
unsigned char az;
}; /* Message 0660 - unnamed struct */
};
struct B1
{
unsigned int bx;
union B2
{
unsigned long by;
unsigned char bz[4];
}; /* Message 0660 - unnamed union */
};
union C1
{
unsigned int cx;
union C2
{
unsigned long cy;
unsigned char cz[4];
}; /* Message 0660 - unnamed union */
};
union D1
{
unsigned int dx;
struct D2
{
unsigned char dy;
unsigned char dz;
}; /* Message 0660 - unnamed struct */
};
struct E1
{
unsigned char ex;
unsigned int; /* Message 0660 - unnamed int */
unsigned char ey;
};
extern struct A1 ast;
extern void foo(void)
{
unsigned int uia;
unsigned char uca;
uia = ast.ax;
uca = ast.ay; /* Message 0662 */
}
MISRA C:2012 Rules applicable to message 0660:
| Rule-1.2 (Advisory) | Language extensions should not be used |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |