MISRA Discussion Forums
sample comment for Rule 21.1 - 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.21 Standard libraries (https://forum.misra.org.uk/forumdisplay.php?fid=176)
+---- Thread: sample comment for Rule 21.1 (/showthread.php?tid=1050)



sample comment for Rule 21.1 - satoshi - 17-04-2014

In p.166, there are the following examples.

Quote:#define defined /* Non-compliant - reserved identifier */

And, It is written as follows in the "amplification":
  • Identifiers or macro names beginning with underscore.
  • Identifiers in file scope described in Section 7

I was thinking "the identifiers which is limited by this rule is
the identifiers(ex. memcpy, errno, ...) that defined in the library section of the C90/C99."

If the rationale of the comment is the following statement, can I be considered that the normal reserved identifiers(ex. int, typedef, ...) are OK?
Of course, although not preferred, int or etc. are excluded as rule 21.1?

Quote:This rule prohibits the use of #define or #undef on th identifier defined as ...

-----
Best regards,
Satoshi Kawajiri


Re: sample comment for Rule 21.1 - misra-c - 20-05-2014

The amplification of Rule 21.1 lists the reserved identifiers and names that are covered by this rule. This mainly covers identifiers / names found in section 7 of the library, but also includes "defined" as you mention.

Keywords ( e.g. int , typedef . . ) are not "reserved identifiers" and are not covered by this rule. However, any attempt to use #define on a keyword will violate rule 20.4
"A macro shall not be defined with the same name as a keyword"