Macros in ANSI C

Checkpoint Technologies ckp at grebyn.com
Sun Mar 3 16:51:23 AEST 1991


In article <1172 at intelisc.isc.intel.com> mojy at iSC.intel.com (Mojy Mirashrafi) writes:
>In the old C if you wanted to define a macro to convert its parameter to a 
>char you would write a macro like this:
>#define conv(s) 's'
>and if you used "conv(X)" in your code you would get 'X'.
>In ANSI C the "'" prevents evaluation of the enclosed characters.

If you don't need it to result in a constant, you can use:

#define conv(s) #s[0]

The real answer is, no, you can't use that old trick anymore, and
no new trick replaces it.  Sorry.
-- 
First comes the logo: C H E C K P O I N T  T E C H N O L O G I E S      / /  
                                                                    \\ / /    
Then, the disclaimer:  All expressed opinions are, indeed, opinions. \  / o
Now for the witty part:    I'm pink, therefore, I'm spam!             \/



More information about the Comp.lang.c mailing list