The C standard says this about preprocessing directives (C99 - 6.10(2) - Preprocessing directives):
A preprocessing directive consists of a sequence of preprocessing tokens that begins with
a # preprocessing token that (at the start of translation phase 4)
...
and (C99 - 6.10(7)):
The preprocessing tokens within a preprocessing directive are not subject to macro
expansion unless otherwise stated.
EXAMPLE In:
#define EMPTY
EMPTY # include <file.h>
the sequence of preprocessing tokens on the second line is not a preprocessing directive, because it does not begin with a # at the start of translation phase 4, even though it will do so after the macro EMPTY has been replaced
So, no, macros cannot expand into a '#include
' preprocessing directive. Those directives need to be in place at the start of translation phase 4 (when handling those directives takes place preprocessing happens). Since macro expansion occurs during phase 4, macros can't cause something to exist at the start of phase 4.
I'd like to point out however, that the following does work:
#ifdef WIN32
#define PLATFORM_HEADER "platform/windows/platform.h"
#else
#define PLATFORM_HEADER "platform/linux/platform.h"
#include PLATFORM_HEADER
because the C standard says this (C99, 6.10.2(4) - Source file inclusion):
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.)