Preprocessor macro to quote its argument

R. Kym Horsell vu0310 at bingvaxu.cc.binghamton.edu
Mon Aug 20 17:59:55 AEST 1990


Sorry about the bandwidth, but... If you *want* to quote something
*after* is has been expanded try this:

#define	Q2(x)	#x
#define	Q(x)	Q2(x)
#define	foo	bar

main(){
	puts(Q(foo));
	}

Ugly?  But it works (if you've an ansii comp).

-Kym Horsell



More information about the Comp.lang.c mailing list