Kenneth said:
Gordon Burditt wrote:
[...]
You can do:
#define INCLUDE_THIS_FILE "god.awful.mess"
#include INCLUDE_THIS_FILE
but I don't see a whole lot of use for it.
I was under the impression (both from experience, and asking here[1]) that
the above is not valid. Someone posted elsethread the same "solution",
and quoted C&V from C99, so perhaps it's valid C99, but not C90?
Nope. My C89 last public draft contains about the same text (3.8.2).
Both the draft and the C99 standard contain this text and example:
,---
A preprocessing directive of the form
# include pp-tokens new-line
(that does not match one of the two previous forms) is permitted. The
preprocessing tokens after include in the directive are processed just
as in normal text. (Each identifier currently defined as a macro name
is replaced by its replacement list of preprocessing tokens.) The
directive resulting after all replacements shall match one of the two
previous forms./77/ The method by which a sequence of preprocessing
tokens between a < and a > preprocessing token pair or a pair of
characters is combined into a single header name preprocessing token
is implementation-defined.
[...]
This example illustrates a macro-replaced #include directive:
#if VERSION == 1
#define INCFILE "vers1.h"
#elif VERSION == 2
#define INCFILE "vers2.h"
/* and so on */
#else
#define INCFILE "versN.h"
#endif
/*...*/
#include INCFILE
+----
77. Note that adjacent string literals are not concatenated into a
single string literal (see the translation phases in $2.1.1.2); thus
an expansion that results in two string literals is an invalid
directive.
`---
Cheers
Michael