A hypothetical question: Is it possible to have a C++ program, which includes preprocessor directives, entirely on one line?
Such a line would look like this:
#define foo #ifdef foo #define bar #endif
What are the semantics of such a line?
Further, are there any combinations of directives which are impossible to construct on one line?
If this is compiler-specific then both VC++ and GCC answers are welcome.
A preprocessing directive must be terminated by a newline, so this is actually a single preprocessing directive that defines an object-like macro, named
foo, that expands to the following token sequence:Any later use of the name
fooin the source (until it is#undefed) will expand to this, but after the macro is expanded, the resulting tokens are not evaluated as a preprocessing directive.This is not compiler-specific; this behavior is defined by the C and C++ standards.