https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021

--- Comment #15 from eggert at cs dot ucla.edu ---
(In reply to Andreas Schwab from comment #14)
> I don't follow.  It works exactly the same way.

Let me try to explain further. In my comment #11, the first directive:

#warning "You are too close to the curb"

generates this diagnostic:

In file included from foo.c:1:
bar.h:1:2: warning: #warning "You are too close to the curb" [-Wcpp]
    1 | #warning "You are too close to the curb"
      |  ^~~~~~~

which contains "You are too close to the curb" twice. In contrast, the second
directive

#warning "Tomorrow is the deadline for paying taxes"

generates only this diagnostic:

In file included from foo.c:1:
baz.h:100:2: warning: #warning "Tomorrow is the deadline for paying taxes"
[-Wcpp]

and this contains "Tomorrow is the deadline for paying taxes" only once, which
is the win I'm suggesting. GCC treats the two #warning directives differently,
and does so because of the intervening #line directive.

Reply via email to