Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!mips!bridge2!jarthur!mti!adrian From: adrian@mti.mti.com (Adrian McCarthy) Newsgroups: comp.lang.c Subject: Re: Preprocessor macro to quote its argument Summary: Egg on my face Message-ID: <1114@mti.mti.com> Date: 19 Aug 90 19:39:46 GMT References: <1112@mti.mti.com> Reply-To: adrian@mti.UUCP (Adrian McCarthy) Organization: Micro Technology, Anaheim, CA Lines: 19 In article <1112@mti.mti.com> adrian@mti.UUCP I wrote: >Ever needed a preprocessor macro that could quote its argument? [...] > #define Q " > #define Q1(x) Q x " It has been pointed out by several kind folks that this is *not* ANSI-compliant. ANSI preprocessors do the tokenization of the input for the rest of the compiler (thus ``preprocessor'' is arguably a misnomer), so the #define lines would generate errors since the unpaired double-quote is an incomplete token. For ANSI preprocessors, use: #define Q1(x) #x For pre-ANSI preprocessors, the original solution *may* work. Reportedly, #define Q1(x) " x " may even work with many pre-ANSI preprocessors, though not VAX C. OK, so I was wrong, Aid. (adrian@gonzo.mti.com)