MISRA Discussion Forums
Rule 20.2 - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.20 Preprocessing directives (https://forum.misra.org.uk/forumdisplay.php?fid=175)
+---- Thread: Rule 20.2 (/showthread.php?tid=1405)



Rule 20.2 - kalpak - 08-03-2018

Why is
#include "c:\headers\measurement_regs.h "
non compliant to rule 20.2 due to \ in the path?


Re: Rule 20.2 - dg1980 - 09-03-2018

It is undefined in the C Standard (Annex J.2) hence the MISRA rule:

Quote:The behavior is undefined in the following circumstances:
...
The characters ', \, ", //, or /* occur in the sequence between the < and >
delimiters, or the characters ', \, //, or /* occur in the sequence between the "
delimiters, in a header name preprocessing token (6.4.7).

Your example is even worse because you use a hard-coded drive letter.
Either use your compiler´s include path and change to or at least use relative paths with '/', e.g.


Re: Rule 20.2 - misra-c - 16-04-2018

The "\" is not permitted for the reasons mentioned by dg1980. A deviation is necessary, which will require you to confirm that "\" behaves as required on your system. Some implementations will accept the use of "/" instead of "\".