cpp behaviour change

Zack Weinberg zack@wolery.cumb.org
Wed Jun 21 17:01:00 GMT 2000

On Thu, Jun 22, 2000 at 01:41:56AM +0200, Falk Hueffner wrote:
> Hi,
> I found out that this:
> #define FOO(V) printf("baz " ## #V);
> FOO(bar);
> will be converted by cpp 2.96 to
> printf("baz "#bar);;
> while 2.95.2 produced
> printf("baz ""bar"); ;
> Can anybody tell me which behaviour is correct?

C99 section paragraph 2: ... The order of evaluation of # and
## operators is unspecified.

The current cpp chooses to go strictly left-to-right; the older one
did all the # operators first.  Either choice is allowed.

If this fragment is intended to be fed to the C compiler, then the ##
is unnecessary.  You can put as much whitespace as you want (including
comments) between consecutive string constants, and they will still be

If you are using cpp to process something other than C source, please
use M4 instead.


More information about the Gcc-bugs mailing list