[previous] MISRA-C:2004  Rule  5.4:  (Required) [next] A tag name shall be a unique identifier.
No tag name shall be reused either to define a different tag or for any other purpose within the program. ISO/IEC 9899:1990 [2] does not define the behaviour when an aggregate declaration uses a tag in different forms of type specifier (struct or union). Either all uses of the tag should be in structure type specifiers, or all uses should be in union type specifiers, For example:

struct stag { uint16_t a; uint16_t b; };

struct stag a1 = { 0, 0 };     /* Compliant - compatible with above   */
union stag  a2 = { 0, 0 };     /* Not compliant - not compatible with
                                  previous declarations               */

void foo( void )
{
    struct stag { uint16_t a; }; /* Not compliant - tag stag redefined  */
}

The same tag definition shall not be duplicated anywhere in the source code files even if the definitions are identical. Where the tag definition is made in a header file, and that header file is included in multiple source files, this rule is not violated.


QAC messages that encompass this guideline:

0547 [C] This declaration of tag '%s' conflicts with a previous declaration.


Related rules:

Rule  1.1 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



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents