Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sample comment for Rule 21.1
#1
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
<t></t>
#2
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


Forum Jump:


Users browsing this thread: 1 Guest(s)