Rule 2.4 and tags the same as typedef names

Moderators: misra-c, david ward

Post Reply
nduru
Posts: 1
Joined: Wed May 29, 2013 9:05 am
Company: sizetheory ltd

Rule 2.4 and tags the same as typedef names

Post by nduru » Fri Jul 18, 2014 4:53 pm

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 ?

misra-c
Posts: 548
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 2.4 and tags the same as typedef names

Post by misra-c » Wed Aug 13, 2014 8:25 am

The phrase "struct coord" is redundant if it is not used anywhere else in the code. The code could be rewritten as

Code: Select all

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.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.2 Unused code”