This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: macro expansion
- From: Ian Lance Taylor <iant at google dot com>
- To: Matti Linsu <matti dot linsu at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 01 Sep 2010 07:36:57 -0700
- Subject: Re: macro expansion
- References: <335131.11252.qm@web120611.mail.ne1.yahoo.com> <mcrfwxueg0p.fsf@google.com> <760009.22750.qm@web120611.mail.ne1.yahoo.com>
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