MISRA Discussion Forums
Rule 2.4 and tags the same as typedef names - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.2 Unused code (https://forum.misra.org.uk/forumdisplay.php?fid=157)
+---- Thread: Rule 2.4 and tags the same as typedef names (/showthread.php?tid=1081)



Rule 2.4 and tags the same as typedef names - nduru - 18-07-2014

Rule 2.4 states that a project should have no unused tag declarations. However in Rule 5.7, a tag name shall be a unique identifier, there is an exception that allows the tag to be the same as the typedef name. You give this example:
typedef struct coord
{
uint16_t x;
uint16_t y;
} coord; /* Compliant by exception */

Can this also be an exception to 2.4 ?


Re: Rule 2.4 and tags the same as typedef names - misra-c - 13-08-2014

The phrase "struct coord" is redundant if it is not used anywhere else in the code. The code could be rewritten as
Code:
typedef struct
{
uint16_t x;
uint16_t y;
} coord;
The exception in rule 5.7 assumes that "struct coord" has been used some-where else in the code.