Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!srcsip!nic.MR.NET!thor.acc.stolaf.edu!agnes!mike From: mike@agnes.uucp (Mike Haertel) Newsgroups: comp.lang.c Subject: token concatenation, #include, and all that Message-ID: <1876@thor.acc.stolaf.edu> Date: 18 Apr 89 20:57:39 GMT Sender: news@thor.acc.stolaf.edu Reply-To: mike@stolaf.edu Lines: 28 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 In Hell they run VMS.