Preprocessor macro to quote its argument
Henry Spencer
henry at zoo.toronto.edu
Sun Aug 26 10:27:10 AEST 1990
In article <21594 at grebyn.com> ckp at grebyn.UUCP (Checkpoint Technologies) writes:
>Why can't this work?
>#define CTRL(ch) ((* #ch) - 64)
>Now, I know this *could* be a constant expression...
3.4 says that the value of an object may not be accessed by a `*' operator
in a constant expression, so this isn't a constant expression in a portable
sense. However, it is not a constraint violation, so the compiler is not
*required* to complain about it, and 3.4 does explicitly authorize compilers
to accept "other forms" of constant expression. So your comment is correct:
it *could be* a constant expression, but isn't dependably one. Alas, one
use of the `CTRL(D)' hack is in case labels, where constant expressions are
required.
--
Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology
-Freeman Dyson | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list