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.