sample comment for Rule 21.1

Moderators: misra-c, david ward

Post Reply
Posts: 7
Joined: Fri Oct 18, 2013 2:31 am
Company: Renesas Solutions Corp.

sample comment for Rule 21.1

Post by satoshi » Thu Apr 17, 2014 4:06 am

In p.166, there are the following examples.
#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?
This rule prohibits the use of #define or #undef on th identifier defined as ...
Best regards,
Satoshi Kawajiri

Posts: 561
Joined: Thu Jan 05, 2006 1:11 pm

Re: sample comment for Rule 21.1

Post by misra-c » Tue May 20, 2014 12:41 pm

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

Post Reply

Return to “8.21 Standard libraries”