mike@agnes.uucp (Mike Haertel) (04/19/89)
This question pertains to the ANSI C preprocessor (pick your brand, as long as it conforms to the pANS. I use GNU's.) Suppose I have a macro ARCH defined as follows: #define ARCH "vax" I would like to be able to say something like: #include archhdr("limits.h") and have it expand to something like: #include "vax/limits.h" Is there any way to do this? I know I could do (fake) something similar: #define ARCH vax #define str(x) #x #define xstr(x) str(x) #define archhdr(x) xstr(ARCH##/##x) /* formally undefined but it works with gcc */ #include archhdr(limits.h) However, this doesn't work if someone has #defined vax to be something else (like, say, 1, but who would do a silly thing like that? :-). Mike Haertel <mike@stolaf.edu> In Hell they run VMS.