Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!usc!jarthur!nntp-server.caltech.edu!eql.caltech.edu!rankin From: rankin@eql.caltech.edu Newsgroups: comp.lang.c Subject: Re: Preprocessor macro to quote its argument Summary: no need to malign VAX C Message-ID: <1990Aug19.204802.1@eql.caltech.edu> Date: 20 Aug 90 04:48:02 GMT References: <1112@mti.mti.com> <1114@mti.mti.com> Sender: news@laguna.ccsf.caltech.edu Reply-To: rankin@eql.caltech.edu Organization: Environmental Quality Laboratory, Caltech Lines: 28 [ He wants to turn a macro argument into a quoted string, which is done significantly differently in ANSI C than in 'traditional' C. ] In article <1114@mti.mti.com>, adrian@mti.mti.com (Adrian McCarthy) writes: >[text deleted] > 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. The second method works fine in VAX C (which is not [yet?] ANSI compliant). The preprocessor is just an internal phase of the integrated compiler, but that doesn't make any difference in a case like this. $ type t.c !t.c is a trivial test file #define Q1(x) " x " char *string = Q1(xyzzy); $ cc/preprocess_only t !read t.c, write t.i $ type t.i !display the result # 1 "USER:[RANKIN]T.C;1" char *string = " xyzzy "; Older versions of the compiler didn't support an explicit preprocess- only option, but they still did the macro substitution this way. Pat Rankin, rankin@eql.caltech.edu