TITLE: Stringizing a macro PROBLEM: jamshid, 25 Feb 94 I don't think I can claim credit for the STR_(x) technique -- I probably learned it the comp.lang.c FAQ (see ~jamshid/faq/c.faq). RESPONSE: -----This article is Copyright 1988, 1990-1993 by Steve Summit.-------- 5.4: I'm trying to use the ANSI "stringizing" preprocessing operator # to insert the value of a symbolic constant into a message, but it keeps stringizing the macro's name rather than its value. A: You must use something like the following two-step procedure to force the macro to be expanded as well as stringized: #define str(x) #x #define xstr(x) str(x) #define OP plus char *opname = xstr(OP); This sets opname to "plus" rather than "OP". An equivalent circumlocution is necessary with the token-pasting operator ## when the values (rather than the names) of two macros are to be concatenated. References: ANSI Sec. 3.8.3.2, Sec. 3.8.3.5 example p. 93.