Preprocessor macro to quote its argument
R. Kym Horsell
vu0310 at bingvaxu.cc.binghamton.edu
Sun Aug 26 04:03:41 AEST 1990
In article <21594 at grebyn.com> ckp at grebyn.UUCP (Checkpoint Technologies) writes:
\\\
>(This is just off the top of my head, so please be gentle...)
>
>Why can't this work?
>
>#define CTRL(ch) ((* #ch) - 64)
>
>It's ANSI only. The single # places it's arg in double quotes, making a
>string, and the * returns the first byte of the string.
This is fine (and I think has been pointed out recently on this
newsgroup). A slight improvement may be
#define CTRL(c) ((*#c)&037)
'though.
-Kym Horsell
More information about the Comp.lang.c
mailing list