Let's say I have two files, a.h
:
#if 1
#include "b.h"
and b.h
:
#endif
Both gcc's and clang's preprocessors reject a.h
:
$ cpp -ansi -pedantic a.h >/dev/null
In file included from a.h:2:0:
b.h:1:2: error: #endif without #if
#endif
^
a.h:1:0: error: unterminated #if
#if 1
^
However, the C standard (N1570 6.10.2.3) says:
A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the
"
delimiters.
which appears to permit the construct above.
Are gcc and clang not compliant in rejecting my code?