MISRA Discussion Forums
Preprocessor directives and white space - 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: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.19 Preprocessing Directives (https://forum.misra.org.uk/forumdisplay.php?fid=43)
+---- Thread: Preprocessor directives and white space (/showthread.php?tid=563)



Preprocessor directives and white space - JonM - 25-07-2008

Rule 19.16 of MISRA C2 requires "In particular, ensure that #else and #endif directives are not followed by any characters other than white-space."

Does this rule apply to the end of the line or just the character following the 'e' or 'f'.

e.g.

Code:
#endif
/* header file exclusion */
vs
Code:
#endif /* header file exclusion */
vs
Code:
#endif/*header file exclusion */

Which of these is allowed / preferred / not allowed by MISRA C

Jonathan


Re: Preprocessor directives and white space - misra-c - 24-09-2008

Quote:Does this rule apply to the end of the line or just the character following the 'e' or 'f'.

The rule applies to all the characters following the last character of the pre-processor directive to the end of the line.

Quote:Which of these is allowed / preferred / not allowed by MISRA C
All three forms are acceptable. Style is not addressed by MISRA C.

The sentence

Quote:In particular, ensure that #else and #endif directives are not followed by any characters other than white-space.

should be read as the following

Quote:In particular, ensure that #else and #endif directives are followed by white space.

ISO-C90:6.1 states that preprocessing tokens can be separated by white space which consists of comments, or white-space characters (space, horizontal tab, new-line, vertical tab, and form-feed), or both.

[ID:0000012]