This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Diagnostic Messaging Suggestion
- From: Arthur Schwarz <aschwarz1309 at verizon dot net>
- To: James Dennett <james dot dennett at gmail dot com>
- Cc: gcc at gcc dot gnu dot org, Ian Lance Taylor <iant at google dot com>
- Date: Thu, 16 Apr 2009 13:53:51 -0700 (PDT)
- Subject: Re: Diagnostic Messaging Suggestion
>
> 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
>
---- Code (unadulterated and full of original lacerations) -----
/*
* File: irange.h
* Author: Arthur Schwarz
*
* Created on April 13, 2009, 1:23 PM
*/
#ifndef _IRANGE_H
#define _IRANGE_H
# include <ios>
# include <iomanip>
# include <istream>
# include <ostream>
# include <fstream>
# include <sstream>
# include "common.h"
class iRange_List : public cDebug{ // input ranges
private:
// Processing of range buffer: <Ndx, Size, BufferSize, Ranges, TempStream>
// Ranges[Ndx] : Ndx<0..BufferSize-1>
// if (Ndx == BufferSize) TempStream.write(Ranges[Ndx]; Size += BufferSize; Ndx = 0;
fstream TempStream; // Temporary Stream
static
long const BufferSize; // Input buffer size
long Ndx; // Index in Ranges buffer
long Size; // Total number ranges used
cRange ErrorRange;
protected:
cRange* Ranges; // All input ranges
long ErrorCount; // Number of errors found
protected:
// double Atod(string& Range, long id);
virtual
void DData () { string str(80, ' ');
ostringstream stream(str);
stream << "iRange_List<"
<< setw(9) << Ndx << ", "
<< setw(9) << Size << ", "
<< setw(9) << ErrorCount << ">" << endl;
cDebug::DData(str);
};
long Next() { if ( ++Ndx < BufferSize) return Ndx;
TempStream.write((char*)Ranges, sizeof(Ranges));
Size += BufferSize;
return (Ndx = 0);
};
void Flush();
public:
iRange_List();
iRange_List(const iRange_List& orig);
virtual ~iRange_List();
long GetSize() { return Size; }
void PrintRange() { for(long i = 0; i < Ndx; i++) Stdout << setw(9) << i << ": "
<< Ranges[i]
<< endl;
}; // PrintRange()
virtual
bool Read() = 0;
cRange& operator[](long Ndx) { return ((Ndx >=0 ) && (Ndx < Size))? Ranges[Ndx]: ErrorRange; }
}; // class iRange_List
class ciRange_2 : public iRange_List { // <low, high>
public:
struct sRange_2 { double RLo; // Low range value
double RHi; }; // High range value
ciRange_2() : iRange_List() { }
virtual
bool Read();
friend istream& operator>>(istream& stream, ciRange_2::sRange_2& Range);
friend ostream& operator<<(ostream& stream, ciRange_2::sRange_2& Range);
}; // class ciRange_2
class ciRange_3 : public iRange_List { // <low, high, id>
public:
struct sRange_3 { double RLo; // Low range value
double RHi; // High range value
long Datum; }; // User supplied datum
ciRange_3() : iRange_List() { }
virtual
bool Read();
friend istream& operator>>(istream& stream, sRange_3& Range);
friend ostream& operator<<(ostream& stream, ciRange_3::sRange_3& Range);
}; // class ciRange_3
#endif /* _IRANGE_H */
//----------------------------------------
// Debug Streams
//----------------------------------------
istream& operator>>(istream& stream, ciRange_2::sRange_2& Range);
istream& operator>>(istream& stream, ciRange_3::sRange_3& Range);
ostream& operator<<(ostream& stream, ciRange_2::sRange_2& Range) {
stream << setw(9) << Range.RLo << " " << setw(9) << Range.RHi;
}
ostream& operator<<(ostream& stream, ciRange_3::sRange_3& Range) {
stream << setw(9) << Range.RLo << " " << setw(9) << Range.RHi << " " << setw(9) << Range.Datum;
}