Need help with quoting and the CPP

John Parks parks at compass.com
Tue Apr 23 03:25:05 AEST 1991


Brett Bergquist writes:
    Is there any way to expand an argument to a macro and at the same time
    surround it with quotes (making is a quoted string).

Interesting question!  If you have an ANSI CPP, it will take two macros
(here given as STR and QUOTE).

    #define greeting hello Jennifer

    #define STR(x) #x
    #define QUOTE(x) STR(x)

    QUOTE(greeting) will expand to "hello Jennifer"

The ANSI stringization operator stringizes an "unexpanded" actual parameter
list, hence a two-step method is needed to force the expansion.

--
John Parks
Compass Inc.
550 Edgewater Drive
Wakefield, MA 01880

ddddddd



More information about the Comp.lang.c mailing list