Macro parameters getting substituted into strings

Doug Gwyn gwyn at brl-smoke.ARPA
Mon Mar 28 02:15:03 AEST 1988


In article <4253 at hoptoad.uucp> gnu at hoptoad.uucp (John Gilmore) writes:
>In the BSD sources, Keith Bostic and I had to change more than 50 files
>to deal with this.

Don't say that Berkeley wasn't informed of this nonportable usage
many years ago, before X3J11 in fact.  I recall that several of us
pointed it out, to no avail.  (In my System V emulation, when I
needed macros like Berkeley's _IOR, I defined mine the right way.)

>Can you say "Codifying existing practice", boyz and goils?

Can you say, "codifying existing correct practice"?

Macro substitution inside string literals and character constants was
explicitly disallowed by K&R, and many independent implementations of
C followed the rule.  For such implementations, requiring the Reiser
cpp behavior would have been a change to existing practice with
visible adverse effects on existing correct code, and there is more
support for their point of view than for that of Reiser cpp abusers.

>My preferred way to fix this would be for ANSI C to allow the *
>(indirection) and [] (subscripting) operators on string literals in
>constant expressions.

I could support this, or some char-ize operator, but I don't think
they'll make it into the standard at this point.  Char-ize had been
proposed before in several forms; I forget whether subscripted
string literals in constant expressions had ever been proposed.

Send it in.



More information about the Comp.lang.c mailing list