'#' in macros (ANSI C)
Urs Hoelzle
urs at polya.Stanford.EDU
Fri Mar 17 05:30:45 AEST 1989
What are the semantics of # within preprocessor macros in ANSI C
implementations? When preprocessing the following code fragment,
different compilers seem to disagree what should be done:
#define Test1(x) #x
#define Test2 # /* is this legal? */
#define Test3(x) \#x
Test1(hello) /* stringization - no problem */
Test2
Test3(hello) /* what should happen here? */
What does ANSI say about this? I couldn't find any answers in H&S
or K&R. In particular, should the last line produce '#hello' or
'\"hello"' ?
-Urs
More information about the Comp.lang.c
mailing list