Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!unhd!al From: al@uunet!unhd (Anthony Lapadula) Newsgroups: comp.lang.c Subject: Re: Preprocessor macro to quote its argument Message-ID: <1990Aug19.200440.8534@uunet!unhd> Date: 19 Aug 90 20:04:40 GMT References: <1112@mti.mti.com> <3857@bingvaxu.cc.binghamton.edu> Reply-To: al@unhd.UUCP (Anthony Lapadula) Organization: Computing Information Services, University of New Hampshire Lines: 33 In article <3857@bingvaxu.cc.binghamton.edu> vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) writes: >In article <1112@mti.mti.com> adrian@mti.UUCP (Adrian McCarthy) writes: >>Ever needed a preprocessor macro that could quote its argument? I did for >\\\ >> #define Q " >> #define Q1(x) Q x " > > >Whatever happened to > >#define Q(x) #x > >? > >-Kym Horsell What happens if Q is ``invoked'' with another macro as its argument, as in: #define M1 100 #define M2 func() : puts (Q(M1)); puts (Q(M2)); What should the output be? The two compilers available to me disagree. gcc version 1.37.1 ---> outputs "M1" and "M2" cc ---> CPP error ("#100 undefined [in puts(#100)]) These results are for a DECstation 5000. -- Anthony (uunet!unhd!al, al@unh.edu) Lapadula // Wanted: catchy .sig.