Why all this fuss about CTRL(X) ??
arnold at emory.UUCP
arnold at emory.UUCP
Wed Dec 24 04:05:45 AEST 1986
I hope somebody hasn't beat me to this. The whole fuss about
#define CTRL(X) ('X' & 037) /* ascii! */
in the Reiser cpp not being doable in ANSI C can be answered this way:
#define CTRL(X) (' ## X ## ' & 037) /* ascii only */
which uses the token concatenation operator to produce the character
constant. This should also work for things like
esc = CTRL([);
I am sure someone will correct me if I am wrong. Now, we can hopefully put
this to rest!
( Personally, I think CTRL(X) is bad style;
#define ctrl(x) ((x) & 037)
and using ctrl('x') makes the most sense to me. It is legal in both K&R C and
ANSI C, and allows using the macro on a char or int variable, not just on
a constant. So there. :-)
--
Arnold Robbins
CSNET: arnold at emory BITNET: arnold at emoryu1
ARPA: arnold%emory.csnet at csnet-relay.arpa
UUCP: { akgua, decvax, gatech, sb1, sb6, sunatl }!emory!arnold
More information about the Comp.lang.c
mailing list