macro expansion

Ian Lance Taylor
Wed Sep 1 14:37:00 GMT 2010

Matti Linsu <> writes:

>> There is a space after 0_start_with_a_number because gcc emits a space
>> whenever necessary to prevent tokens from accidentally pasting together.
>> E.g., a space is required between '+' and '=' in preprocessor output.
>> The test for whether a space is necessary is conservative.
>> 0_start_with_a_number is not an identifier, so the conservative test
>> says that a space is required.
> Could you give an example where tokens would accidentally be pasted together?
> I cannot find any case where it would happen.

I implied an example.  Here it is in more detail:

#define P() +
#define E() =

The preprocessor must insert a space between the '+' and the '=',
otherwise it will produce the single token '+='.  On the other hand:

#define A() &

The preprocessor does not have to preserve that space, because '+&' is
always two tokens, and indeed gcc's preprocessor does not preserve it.


More information about the Gcc-help mailing list