2.4 violation?

Moderators: misra-c, david ward

Post Reply
gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

2.4 violation?

Post by gs » Tue Jan 28, 2014 5:54 pm

Does the following example violate rule #2.4:

Code: Select all

typedef enum A {
    b
} A;

A c() {
    return b;
}

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

Re: 2.4 violation?

Post by misra-c » Mon Feb 10, 2014 2:09 pm

Your example does violate rule 2.4, providing typedef “A” is always used in the rest of the translation unit and never “enum A”. A compliant typedef declaration could be written as

Code: Select all

typedef enum {
        b
     } A;
This issue is similar to the example of record_t in the Example section for rule 2.4.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “7.2 Compilation and build”