It could also be done by taking advantage of the fact that adjacent string literals are combined during compilation:
#define debug(a) printf("the value of " #a "is %d\n", a) > -----Original Message----- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On > Behalf Of Charles Mills > Sent: Friday, September 05, 2014 7:00 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: IBM C compiler substituting for macros inside literals? > > Not sure if your question is intended to be serious but on an ANSI C > compiler there is no way to do substitution inside a literal string. > However, what could have been accomplished with this: > > #define debug(a) printf("the value of a is %d\n", a) > > that is, a macro that would print "the value of foo is 27" > > can be accomplished with ANSI "stringification": > > #define debug(a) printf("the value of %s is %d\n", #a, a) > > The preprocessor turns #a into "foo" (including the quotes) > > Charles > -----Original Message----- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On > Behalf Of Martin Packer > Sent: Friday, September 05, 2014 1:57 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: IBM C compiler substituting for macros inside literals? > > So tell me, if one wanted to achieve this apparently non-standard effect how > WOULD one go about it? > > Not that I want to but it HAD to be asked. :-) > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN