C
clark.coleman
I have a header file that compiles fine on Visual Studio .NET 2005 but
has big trouble on x86/Linux using gcc-4.1.1
I need to make sets of elements of type "op_t", which needs a complex
comparison function. Near the top of my header, I include the ehader
that defines "op_t", then I make this ordering function:
class LessOp {
public:
bool operator()(const op_t Opnd1, const op_t Opnd2) const {
if (Opnd1.type != Opnd2.type)
return (Opnd1.type < Opnd2.type);
switch (Opnd1.type) {
etc.
etc.
The first time I make reference to "LessOp" later in the header, I get
the compile errors from gcc but not Visual Studio. The reference is a
public member function of a class, declared as:
set<const op_t, LessOp>::iterator GetFirstLiveIn(void); // First
LiveIn ...
This is line 180 of SMPDataFlowAnalysis.h, as referenced in this gcc
error message:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h: In instantiation of '__gnu_cxx::new_allocator<const
op_t>':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/allocator.h:83: instantiated from 'std::allocator<const op_t>'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_set.h:110: instantiated from 'std::set<const op_t, LessOp,
std::allocator<const op_t> >'
SMPDataFlowAnalysis.h:180: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h:78: error: 'const _Tp*
__gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp =
const op_t]' cannot be overloaded
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h:75: error: with '_Tp*
__gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const
op_t]'
I thought maybe I needed to make the parameters to LessOp's operator
be by reference, so I changed the declaration to be:
class LessOp {
public:
bool operator()(const op_t &Opnd1, const op_t &Opnd2) const {
This produces the exact same error message from gcc, and still no
errors or warnings from Visual Studio.
I have found numerous similar problems in this group and via search
engine, but almost all of them were the opposite problem of people not
using "const" whereas I used "const" all over the place.
Any help is appreciated.
has big trouble on x86/Linux using gcc-4.1.1
I need to make sets of elements of type "op_t", which needs a complex
comparison function. Near the top of my header, I include the ehader
that defines "op_t", then I make this ordering function:
class LessOp {
public:
bool operator()(const op_t Opnd1, const op_t Opnd2) const {
if (Opnd1.type != Opnd2.type)
return (Opnd1.type < Opnd2.type);
switch (Opnd1.type) {
etc.
etc.
The first time I make reference to "LessOp" later in the header, I get
the compile errors from gcc but not Visual Studio. The reference is a
public member function of a class, declared as:
set<const op_t, LessOp>::iterator GetFirstLiveIn(void); // First
LiveIn ...
This is line 180 of SMPDataFlowAnalysis.h, as referenced in this gcc
error message:
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h: In instantiation of '__gnu_cxx::new_allocator<const
op_t>':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/allocator.h:83: instantiated from 'std::allocator<const op_t>'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/
bits/stl_set.h:110: instantiated from 'std::set<const op_t, LessOp,
std::allocator<const op_t> >'
SMPDataFlowAnalysis.h:180: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h:78: error: 'const _Tp*
__gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp =
const op_t]' cannot be overloaded
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/ext/
new_allocator.h:75: error: with '_Tp*
__gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const
op_t]'
I thought maybe I needed to make the parameters to LessOp's operator
be by reference, so I changed the declaration to be:
class LessOp {
public:
bool operator()(const op_t &Opnd1, const op_t &Opnd2) const {
This produces the exact same error message from gcc, and still no
errors or warnings from Visual Studio.
I have found numerous similar problems in this group and via search
engine, but almost all of them were the opposite problem of people not
using "const" whereas I used "const" all over the place.
Any help is appreciated.