This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Diagnostic Messaging Suggestion
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Arthur Schwarz <aschwarz1309 at verizon dot net>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 16 Apr 2009 20:44:53 -0700
- Subject: Re: Diagnostic Messaging Suggestion
- References: <371233.23667.qm@web84004.mail.mud.yahoo.com>
On Thu, Apr 16, 2009 at 03:40:47PM -0700, Arthur Schwarz wrote:
> The rock has dropped. The answer is quoted below:
>
> "My best guess is that a header file is included twice, and lacks guards, hence the message is correct: the function is being defined twice, from the same source location."
Yes, I've had to diagnose this one before; it doesn't happen with my
own code because I use include guards, but I've had to help others.
It would be cool if there were a way of distinguishing the case where
the same header is being processed twice.
We might see
foo.h:11 error: redefinition of `a'
foo.h:11 error: `a' previously defined here
but the first "foo.h:11" might represent the 2300'th line read by the
compiler, while the second "foo.h:11" might represent the 2194'th line.
If, for definitions, the compiler keeps track of this detail, it
would be possible to reliably print
foo.h:11 error: redefinition of `a' (file was included more than once)
if the printable line number is the same but the internal line number
is different.