token pasting (was: how widespread is this cpp bug?)

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Dec 4 15:20:25 AEST 1988


In article <1747 at solo3.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>Why didn't the ANSI committee legalize that current practice, instead of
>defining a new paste operator (##)?

Because there were probably more C implementations that followed the
explicit rule stated in the base document (K&R 1st Ed.) than that
violated it.

Although X3J11 couldn't legalize this behavior, it did recognize the
utility of token pasting, which is why it designed a legal solution
to it.

I suggest adding a paste(a,b) macro to your equivalent of <std.h>,
and define paste(a,b) according to the specific implementation.  Be
advised that many pre-ANSI C implementations cannot implement this
macro.



More information about the Comp.lang.c mailing list