MISRA Discussion Forums
2.4 violation? - 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: 7.2 Compilation and build (https://forum.misra.org.uk/forumdisplay.php?fid=179)
+---- Thread: 2.4 violation? (/showthread.php?tid=1023)



2.4 violation? - gs - 28-01-2014

Does the following example violate rule #2.4:
Code:
typedef enum A {
    b
} A;

A c() {
    return b;
}



Re: 2.4 violation? - misra-c - 10-02-2014

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:
typedef enum {
        b
     } A;
This issue is similar to the example of record_t in the Example section for rule 2.4.