This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: macro expansion


Matti Linsu <matti.linsu@yahoo.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]