[Bug preprocessor/20262] __LINE__ implementation flaky.

neil at daikokuya dot co dot uk gcc-bugzilla@gcc.gnu.org
Tue Mar 1 23:13:00 GMT 2005


------- Additional Comments From neil at daikokuya dot co dot uk  2005-03-01 23:13 -------
Subject: Re:  __LINE__ implementation flaky.

pinskia at gcc dot gnu dot org wrote:-

> 
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-01 17:16 -------
> Outer Macros are expanded before inner ones and they get all placed on one line so this is invalid.

Huh? This is a bug.

The reason it happens is nothing to do with inner or outer macros,
but the fact that arguments are collected before being expanded,
and an implementation detail where we don't take the line from the
token (otherwise __LINE__ would be misexpanded if the RHS of a
macro definition) but from the global line counter.

It may not be worth fixing; I suspect the reason other implementations
fail too is that it's hard to get it right, and the ability to easily
do so is heavily dependent on exactly how your preprocessor is
implemented.  (a bit like the #s vs %:s bug).

Neil.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20262



More information about the Gcc-bugs mailing list