Quantcast
Browsing latest articles
Browse All 5 View Live

Answer by rodrigo for Can #endif in an included file be used to close a #if...

I think the compilers are right, or at best the standard is ambiguous. The trick is not in how #include is implemented, but in the order in wich preprocessing is done. Look at the grammar rules in...

View Article


Answer by Keith Thompson for Can #endif in an included file be used to close...

The C standard defines 8 translation phases. A source file is processed by each of the 8 phases in sequence (or in an equivalent manner). Phase 4, as defined in N1570 section 5.1.1.2, is: Preprocessing...

View Article


Answer by mw215 for Can #endif in an included file be used to close a #if in...

Thinking of a C preprocessor as a very simple compiler, to translate a file a C preprocessor conceptually carries out a few phases. Lexical analysis – Groups the sequence of characters making up the...

View Article

Answer by gnasher729 for Can #endif in an included file be used to close a...

#if / #ifdef / #ifndef #elif #else #endif must be matched within one file.

View Article

Can #endif in an included file be used to close a #if in the including file?

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:...

View Article

Browsing latest articles
Browse All 5 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>