MISRA Discussion Forums

Full Version: sample comment for Rule 21.1
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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"