This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Diagnostic Messaging Suggestion
- From: James Dennett <james dot dennett at gmail dot com>
- To: Arthur Schwarz <aschwarz1309 at verizon dot net>
- Cc: gcc at gcc dot gnu dot org, Ian Lance Taylor <iant at google dot com>
- Date: Thu, 16 Apr 2009 12:48:37 -0700
- Subject: Re: Diagnostic Messaging Suggestion
- References: <877597.28655.qm@web84004.mail.mud.yahoo.com>
On Thu, Apr 16, 2009 at 12:06 PM, Arthur Schwarz
<aschwarz1309@verizon.net> wrote:
>
>
>
> Suggested Messaging: Messaging seems redundant in indicating that function has been redifined twice. One of the messages should be removed. More to the point, I think the messaging may be erroneous - code fragment follows.
>
>
> g++-4 Diagnostic Messaging
>
> In file included from partition.cpp:66:
> irange.h: In function 'std::ostream& operator<<(std::ostream&, ciRange_2::sRange_2&)':
> irange.h:102: error: redefinition of 'std::ostream& operator<<(std::ostream&, ciRange_2::sRange_2&)'
> irange.h:102: error: 'std::ostream& operator<<(std::ostream&, ciRange_2::sRange_2&)' previously defined here
>
>
> ---- Code Fragment ----
> class ciRange_2 : public iRange_List { ? ? ? ? ? // <low, high>
> public:
> ? ?struct sRange_2 { double RLo; ? ? ? ? ? ? ? ?// Low ?range value
> ? ? ? ? ? ? ? ? ? ? ?double RHi; }; ? ? ? ? ? ? // High range value
>
> ? ?friend istream& operator>>(istream& stream, ciRange_2::sRange_2& Range);
> ? ?friend ostream& operator<<(ostream& stream, ciRange_2::sRange_2& Range);
> }; // class ciRange_2
>
> istream& operator>>(istream& stream, ciRange_2::sRange_2& Range);
>
> ostream& operator<<(ostream& stream, ciRange_2::sRange_2& Range) {
> ? stream << setw(9) << Range.RLo << " " << setw(9) << Range.RHi;
> }
Can you show code that reproduces the issue? 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.
-- James