Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MISRA rule 20.1 and 20.2
#2
Your example contains a constraint error and therefore violates rule 1.1. Section 6.1.2 of the C90 standard states
Quote:In translation phases 7 and 8, an identifier shall not consist of the same sequence of characters as a keyword.
This statement does not apply to the pre-preprocessor, and so rule 20.1 covers macro names with the same names as keywords, but rule 20.2 does not need to include keywords. This was clarified in the MISRA-C:2004 Technical Corrigendum 1 and discussed in the Bulletin Board at http://www.misra-c2.com/forum/viewtopic.php?t=291.

Rule 20.1 restricts the identifier names which may be used with the #define and #undef pre-processor directives. For Example:
Code:
#define sqrt   x  
#define for  x
#undef EOF

Rule 20.2 refers to the declaration of non-preprocessor names. e.g. objects, function names, typedefs. For Example:
Code:
int strlen;
int strlen ( void )
typedef int strlen;

Rule 1.1 covers constraint errors. For Example:
Code:
int for;
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)