What is a constant expression
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Oct 19 20:18:28 AEST 1989
In article <1219 at crdos1.crd.ge.COM> davidsen at crdos1.UUCP (bill davidsen) writes:
> #define CNTL(c) ('c' & 037)
> What am I missing in the standard? In looking up initializers in the
>index, section 3.5.7 (L14) uses the term "constant expression." However
>the index doesn't seem to list that term.
Sure it does:
constant expressions, 3.4
> Don't waste your time telling me that's a bad way to do the macro, I
>didn't write it, and I don't defend it.
My recommendation for this abuse of the preprocessor, widely encountered
in code from Berkeley UNIX systems, is to change the macro to
#define CNTRL(c) ((c) & 037)
then globally edit the source code to wrap the arguments with '',
e.g. in "ed":
g/CTRL(/s/CTRL(\(.\))/CNTRL('\1')/g
More information about the Comp.std.c
mailing list