CTRL(X) in ANSI standard (last one I hope)

Ken Arnold%CGL arnold at ucsfcgl.UUCP
Wed May 22 10:30:46 AEST 1985

In article <10747 at brl-tgr.ARPA> Purtill at MIT-MULTICS.ARPA (Mark Purtill) writes:
>I'm suprised no one caught me on this. When I said
>>#define CTRL(XX) ( ($XX)[0] & '\037')
>I should have said
>>#define CTRL(XX) ( (#XX)[0] & '\037')
>(ie, the $ should have been a #!!)  Sorry about that...

Unless the compiler is incredibly smart, this won't work in 'case'
statements, which is rather important.  Although "a"[0] is, in fact,
a constant, it is only a constant because it is a constant offset
into a *constant array*, which is a rather unusual beast.  The VAX
pcc doesn't figure this out.  Try this on your compiler and see if it

		switch (i) {
		  case "a"[0]:

Actually, when you think about it, since strings are writeable, "a"[0]
is NOT a constant, since someone else might modify the string.  It is
an indirection off of a constant location, but it is not a constant.

Face it.  We are going to have to kill ourselves trying to work around
the standard committee's refusal to let C work the way it has been working.
I have made my opinion on this known ad nauseum, I'm sure, so I'll just
leave it alone for now...

		Ken Arnold

More information about the Comp.lang.c mailing list