Re: macro expansion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matti Linsu <matti.linsu@xxxxxxxxx> 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() =
P()E()

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

#define A() &
P()A()

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

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux