compilation error: cannot be overloaded!!!

J

John

Hello,

I am trying to compile C++ code which uses rogue wave 9.0 classes on RHEL
4.0. I use gnu g++ compiler to compile the code.
Compiler is not able to match the right type of parameters to overload the
methods of RW classes.
Below are the two methods among others in the rw/ep_scntn.h header file
where compiler says cannot be overloaded.

RWBoolean contains(RWBoolean(*fn)(const_value,void*),void* x) const;
RWBoolean contains(RWBoolean(*fn)(value_type,void*),void* x) const
{ return base_type::contains(fn,x); }

Compiler is treating the first parameter in above methods as same.

When I issue a make command from one of our c++ module, I get below error

/usr/bin/g++ -g -fpic -D_POSIX_SOURCE -DTRACING -D__EXTENSIONS__ -D__RWCOMPILER_H__
-D_REENTRANT -D_RWCONFIG=8s -D_RWCONFIG_12d -D_RWSTDDEBUG -DRWDEBUG -c
TrackListMap.C -I../inc -I/psalms/common/inc -I/psalms/common/Map/inc -I/psalms/common/Scan/inc
-I/opt/ossasn1/linux-glibc2.2.trial/8.2.0-betaA/include -I/psalms/common/ASNFw2/sep/inc
-I/psalms/common/DbFw/inc -I/psalms/common/DbFwMgr/inc -I/psalms/common/Time/inc
-I/psalms/common/LoggingFw/inc -I/psalms/common/ExcepFw/inc -I/psalms/common/ConfigFw/inc
-I/psalms/common/SdtArm/inc -I/opt/RogueWave/SourcePro -o TrackListMap.o

In file included from ../inc/TrackListMap.h:18,
from TrackListMap.C:15:
/opt/RogueWave/SourcePro/rw/ep_scntn.h: In instantiation of
`RW_PCntnr<std::vector<const RWCString*, std::allocator<const RWCString*> >,
RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >,
const RWCString>':
/opt/RogueWave/SourcePro/rw/ep_seq.h:50: instantiated from
`RW_PSeq<std::vector<const RWCString*, std::allocator<const RWCString*> >,
RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >,
const RWCString>'
/opt/RogueWave/SourcePro/rw/tpordvec.h:65: instantiated from
`RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >'
/psalms/common/Map/inc/MapFile.h:27: instantiated from here
/opt/RogueWave/SourcePro/rw/ep_scntn.h:92: error: `RWBoolean
RW_PCntnr<StdColl, RWColl, T>::contains(RWBoolean (*)(typename
StdColl::value_type, void*), void*) const [with StdColl = std::vector<const
RWCString*, std::allocator<const RWCString*> >, RWColl =
RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >, T =
const RWCString]' and `RWBoolean RW_PCntnr<StdColl, RWColl,
T>::contains(RWBoolean (*)(const T*, void*), void*) const [with StdColl =
std::vector<const RWCString*, std::allocator<const RWCString*> >, RWColl =
RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >, T =
const RWCString]' cannot be overloaded
/opt/RogueWave/SourcePro/rw/ep_scntn.cc:96: error: `typename
RW_PCntnr<StdColl, RWColl, T>::value_type RW_PCntnr<StdColl, RWColl,
T>::find(RWBoolean (*)(typename StdColl::value_type, void*), void*) const
[with StdColl = std::vector<const RWCString*, std::allocator<const
RWCString*> >, RWColl = RWTPtrOrderedVector<const RWCString,
std::allocator<const RWCString*> >, T = const RWCString]' and `typename
RW_PCntnr<StdColl, RWColl, T>::value_type RW_PCntnr<StdColl, RWColl,
T>::find(RWBoolean (*)(const T*, void*), void*) const [with StdColl =
std::vector<const RWCString*, std::allocator<const RWCString*> >, RWColl =
RWTPtrOrderedVector<const RWCString, std::allocator<const RWCString*> >, T =
const RWCString]' cannot be overloaded
..........................
...........................


any idea why we get above error. and how to fix the same.

Thanks & Regards,
Prakash
 
R

Ron Natalie

John said:
Hello,

I am trying to compile C++ code which uses rogue wave 9.0 classes on RHEL
4.0. I use gnu g++ compiler to compile the code.
Compiler is not able to match the right type of parameters to overload the
methods of RW classes.
Below are the two methods among others in the rw/ep_scntn.h header file
where compiler says cannot be overloaded.

RWBoolean contains(RWBoolean(*fn)(const_value,void*),void* x) const;
RWBoolean contains(RWBoolean(*fn)(value_type,void*),void* x) const

The probably are the same type. Typedefs do not define new types, just
aliases for other types. Top level const has no bearing on the function
type.

If value_type is T, and const_type is const T, then teh two functions
above have the same signature.
 
N

nikkoara

Compiler is not able to match the right type of parameters to overload the
methods of RW classes.
Below are the two methods among others in the rw/ep_scntn.h header file
where compiler says cannot be overloaded.

RWBoolean contains(RWBoolean(*fn)(const_value,void*),void* x) const;
RWBoolean contains(RWBoolean(*fn)(value_type,void*),void* x) const
{ return base_type::contains(fn,x); }
[...]
any idea why we get above error. and how to fix the same.

Thanks & Regards,
Prakash

Hi Prakash,

The error is caused by the use of a const type as a key in the pointer-
based ordered vector. As Ron pointed out, the two types in the two
overloads of contains member function have the same type as a result
of this. Using:

RWTPtrOrderedVector < RWCString > v;

instead of

RWTPtrOrderedVector < RWCString const > v;

could work around it.

Liviu
 
P

prakash.mirji

The probably are the same type. Typedefs do not define new types, just
aliases for other types. Top level const has no bearing on the function
type.

If value_type is T, and const_type is const T, then teh two functions
above have the same signature.

Hello John,

Thanks for your reply.
But how can I change rogue wave classes?. My class is using rogue wave
SourcePro 9.0.
Is there any flag to compiler to handle this kind of conflict.

Please let me know.

Thanks,
Prakash
 
A

Alf P. Steinbach

* (e-mail address removed):
Hello John,

Thanks for your reply.
But how can I change rogue wave classes?. My class is using rogue wave
SourcePro 9.0.
Is there any flag to compiler to handle this kind of conflict.

Please let me know.

As it happens const_value and value_type are defined in terms of
template parameters.

It would have been a Good Idea to provide those definitions so that we
didn't have to speculate.

It's possible you can change your template parameters.
 
N

nikkoara

Hello John,

Thanks for your reply.
But how can I changerogue waveclasses?. My class is usingrogue wave
SourcePro 9.0.
Is there any flag to compiler to handle this kind of conflict.

Please let me know.

Thanks,
Prakash

Hi Prakash,

It is not advisable to change the Rogue Wave code unless you know
exactly what you are doing.

In case you have missed my previous post I will reiterate my point
again: your error comes from your using of a const type as a template
argument. This causes a clash between typedefs inside the container
pointer hierarchy, one of the results being the error you are seeing.
If you change the type at /psalms/common/Map/inc/MapFile.h:27 from
RWTPtrOrderedVector< const RWCString > to RWTPtrOrderedVector<
RWCString > I believe -- based on the listing of your initial post and
a test case I have created here -- that the error will be avoided.

I strongly advise you in the future to direct your questions on the
Rogue Wave libraries to the developer's forum hosted by our company if
you need a timely response. Addressing such questions directly to our
tech support at Rogue Wave will get you a feed-back faster still.

It is curious that you are using a const type for your container. It
is an unusual choice -- do you have a strong reason for that? It is
worth pointing out that you will get similar errors when instantiating
stdlib containers such as vectors with const types:

$ cat t.cpp
#include <vector>

int
main ()
{
std::vector< int const > v;
return 0;
}

$ g++ -c --pedantic -Wall t.cpp
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
In instantiation of '__gnu_cxx::new_allocator<const int>':
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:83:
instantiated from 'std::allocator<const int>'
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:
78: instantiated from 'std::_Vector_base<const int,
std::allocator<const int> >'
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:
159: instantiated from 'std::vector<const int, std::allocator<const
int> >'
t.cpp:6: instantiated from here
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
78: error: 'const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const
_Tp&) const [with _Tp = const int]' cannot be overloaded
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
75: error: with '_Tp* __gnu_cxx::new_allocator<_Tp>::address(_Tp&)
const [with _Tp = const int]'
[........]

Liviu
 
J

James Kanze

It is not advisable to change the Rogue Wave code unless you know
exactly what you are doing.

Good advice for any third party software, I would say.

[...]
It is curious that you are using a const type for your container. It
is an unusual choice -- do you have a strong reason for that? It is
worth pointing out that you will get similar errors when instantiating
stdlib containers such as vectors with const types:

The standard requires that the instantiation type for standard
containers be copiable and assignable. Const types aren't
assignable. (I'm not familiar with the Rogue Wave components,
but a similar requirement wouldn't surprise me there, either.
It makes sense.)
 
N

nikkoara

It is curious that you are using a const type for your container. It
The standard requires that the instantiation type for standard
containers be copiable and assignable. Const types aren't
assignable. (I'm not familiar with the Rogue Wave components,
but a similar requirement wouldn't surprise me there, either.
It makes sense.)

Rightly so. :) Although my test case is not exactly representative
for our library code, the error is very similar.

The pointer-based containers in our library take the type as argument
but store pointers to type. RWTPtrOrderedVector< int > is equivalent
to std::vector< int* > but RWTPtrOrderedVector< int const > is not
equivalent with std::vector< int const* > (which is I assume the user
actually wanted to have).

Liviu
 
P

prakash.mirji

Hello John,
Thanks for your reply.
But how can I changerogue waveclasses?. My class is usingrogue wave
SourcePro 9.0.
Is there any flag to compiler to handle this kind of conflict.
Please let me know.
Thanks,
Prakash

Hi Prakash,

It is not advisable to change the Rogue Wave code unless you know
exactly what you are doing.

In case you have missed my previous post I will reiterate my point
again: your error comes from your using of a const type as a template
argument. This causes a clash between typedefs inside the container
pointer hierarchy, one of the results being the error you are seeing.
If you change the type at /psalms/common/Map/inc/MapFile.h:27 from
RWTPtrOrderedVector< const RWCString > to RWTPtrOrderedVector<
RWCString > I believe -- based on the listing of your initial post and
a test case I have created here -- that the error will be avoided.

I strongly advise you in the future to direct your questions on the
Rogue Wave libraries to the developer's forum hosted by our company if
you need a timely response. Addressing such questions directly to our
tech support at Rogue Wave will get you a feed-back faster still.

It is curious that you are using a const type for your container. It
is an unusual choice -- do you have a strong reason for that? It is
worth pointing out that you will get similar errors when instantiating
stdlib containers such as vectors with const types:

$ cat t.cpp
#include <vector>

int
main ()
{
std::vector< int const > v;
return 0;

}

$ g++ -c --pedantic -Wall t.cpp
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
In instantiation of '__gnu_cxx::new_allocator<const int>':
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:83:
instantiated from 'std::allocator<const int>'
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:
78: instantiated from 'std::_Vector_base<const int,
std::allocator<const int> >'
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:
159: instantiated from 'std::vector<const int, std::allocator<const
int> >'
t.cpp:6: instantiated from here
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
78: error: 'const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const
_Tp&) const [with _Tp = const int]' cannot be overloaded
/opt/compilers/gcc-4.1.2/lib/gcc/i386-apple-
darwin8.9.1/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:
75: error: with '_Tp* __gnu_cxx::new_allocator<_Tp>::address(_Tp&)
const [with _Tp = const int]'
[........]

Liviu- Hide quoted text -

- Show quoted text -


Thank you Liviu. changing the type at /psalms/common/Map/inc/
MapFile.h from
I strongly advise you in the future to direct your questions on the
Rogue Wave libraries to the developer's forum hosted by our company if
you need a timely response. Addressing such questions directly to our
tech support at Rogue Wave will get you a feed-back faster still.

I will take care this in future.
Can I know the mail id of dev team & tech support team forum?.
It is curious that you are using a const type for your container. It
is an unusual choice -- do you have a strong reason for that? It is
worth pointing out that you will get similar errors when instantiating
stdlib containers such as vectors with const types:

I don't know the exact reason behind using 'const' to our container.
I am porting c++ code which was developed somebody on SOLARIS to RHEL
4.0.

Thank you once again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top