Macros in ANSI C

Arthur David Olson ado at elsie.nci.nih.gov
Tue Mar 5 07:29:28 AEST 1991


> In the old C if you wanted to define a macro to convert its parameter to a 
> char you would. . .
> #define conv(s) 's'
> . . .In ANSI C the "'" prevents evaluation of the enclosed characters.
> . . .Is there a way to escape the "'"s, in ANSI C?

For many practical purposes, what works is to

	#define LETR_A	'A'
	#define LETR_B	'B'
	/* ... */
	#define LETR_Z	'Z'

	#define LETR_a	'a'
	#define LETR_b	'b'
	/* ... */
	#define LETR_z	'z'

	#define conv(s)	((LETR_ ## s) & 037)
-- 
	The Multiprocessor Turing Instruction Set Computer:  TISC-TISC
		Arthur David Olson	ado at elsie.nci.nih.gov
		ADO and Elsie are Ampex and Borden trademarks



More information about the Comp.lang.c mailing list