gcc bug (was: Re: You _CAN_ "stringize" tokens in (some) K&R pre-processors)

Karl Heuer karl at ima.isc.com
Thu Apr 4 13:10:40 AEST 1991


In article <DAVIS.91Apr3215642 at pacific.mps.ohio-state.edu> davis at pacific.mps.ohio-state.edu  (John E. Davis) writes:
>[The program which included]
>   #define quote "
>   #define stringize(a) (quote a"+1)
>...failed to run under gcc...  So does this mean there is a bug in gcc?

No, since the program contains unbalanced quotes (and is therefore incorrect),
the way gcc chooses to resolve the error is no more buggy than the way the
Reiser cpp resolves it.

If you really need stringizing (and few programs do, even if they think so),
then use |#a| with ANSI compilers, |"a"| with compilers that use the Reiser
cpp (or any bug-for-bug compatible cpp), and the above hack on any others.
And when you encounter an implementation where none of them work, complain
to the person who told you that you really needed stringizing.

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list