Macro sustitution inside quotes

Henry Spencer henry at utzoo.uucp
Wed Apr 11 04:50:11 AEST 1990


In article <1284 at necisa.ho.necisa.oz> boyd at necisa.ho.necisa.oz (Boyd Roberts) writes:
>    #define string(s)	# s
>It is not obvious or intuitive what kind of expansion occurs.  Whereas:
>    #define string(s)	"s"
>evaluates in the way you would expect.

Uh, in the way *who* would expect?  I, for one, certainly don't expect
the preprocessing phase to look for "identifiers" inside strings!
Especially since K&R1 outlawed substitution into strings, albeit with
slightly ambiguous language.

>Apart from that, # operators break things.  Why weren't the Reiser
>conventions just formalised?  Oh no, that would be too easy.

The Reiser conventions are almost impossible to implement in many C
compilers, especially the ones that tokenize at preprocessor time
rather than doing preprocessor operations on raw text.  They were never
documented, and in fact they openly violate K&R1, which many non-Unix
C implementors used as the basis for their compilers.  There is no
shortage of existing code which relies on the Reiser botches *not*
being done.  They were not in any sense a de facto standard -- they
were undocumented quirks of the Unix preprocessor.
-- 
Apollo @ 8yrs: one small step.|     Henry Spencer at U of Toronto Zoology
Space station @ 8yrs:        .| uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list