![]() |
![]() |
2547 | ![]() |
||||
![]() | |||||||
| Declarations and definitions | |||||||
This tag declaration will 'hide' another tag with the same name declared previously at a wider scope. The previous declaration will remain hidden for the remainder of this scope. Usage of this identifier which might be intended to refer to the previous tag will now refer to the local one instead. This could be the result of trying to use the same tag for a struct and a union (or an enum). In the C language, all tags occupy the same name space. Hiding of identifiers is confusing and dangerous and should be avoided. For example:
/*PRQA S 750,2017,2213,2216,3408,3629 ++*/
struct XT {int a; int b;};
void foo(void)
{
union XT {float f; long t;}; /* Message 2547 */
}
MISRA C:2012 Rules applicable to message 2547:
| Rule-5.3 (Required) | An identifier declared in an inner scope shall not hide an identifier declared in an outer scope |
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 |