Quote without comment on char constant expansion

Alan J Rosenthal flaps at dgp.toronto.edu
Sun Apr 17 03:22:42 AEST 1988


I'm using the convention of quoting C statements with backquotes since
I need to use forward-quotes and double-quotes.

Discussing that there is no way to write the (revolting in my opinion)
CTRL macro where `CTRL(a)` substitutes to `('a' & 037)`,
tainter at ihlpg.ATT.COM first asks if `"ABCD"[0]` isn't indeed legal ANSI
C (it is), and then assuming that it is says that `(#x[0])`

>becomes a 'charize' expression equivalent to a direct charize operator
>for all intents and purposes.  I can't seriously imagine a compiler not
>optimizing this expression to the character constant.

The optimization is not the problem.  What the problem is is that this
is not a character constant, it is a character-valued expression.  So
where a constant expression is required this cannot be used.  The most
common example for the CTRL macro is a switch statement, in which the
cases must be constant expressions.

ajr

--
":= has got to be the most ugly, most bogus pile of sh*t ever invented,
 but that's my personal opinion."     -- Johnson Noise




More information about the Comp.lang.c mailing list