This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Diagnostic Messaging Suggestion


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]