macros with parameters in MSC 5.0
Larry Jones
scjones at sdrc.UUCP
Fri Feb 19 10:27:19 AEST 1988
In article <11879 at brl-adm.ARPA>, jbaker at ee.UCLA.EDU (Joe Baker) writes:
< #define ctl(c) ('c'&037)
<
< This requires parameter substitution within a character constant, which
< is not allowed in MSC5.0 (My reading of Kernighan & Ritchie pg. 207
< seems to indicate that they don't allow it either. However, the
< program compiles and runs on lots of systems.)
<
< The Microsoft manual suggests use of the 'stringizing' operator, #,
< but this produces a string literal instead of a character constant.
Just stringize and then pick the character you want out of the string:
#define ctl(c) (#c[0]&037)
A sufficiently clever compiler will just compile this into a character
constant.
--
----
Larry Jones UUCP: uunet!sdrc!scjones
SDRC MAIL: 2000 Eastman Dr., Milford, OH 45150
AT&T: (513) 576-2070
"When all else fails, read the directions."
More information about the Comp.lang.c
mailing list