Template redefinition problem

A

Attila Feher

lomat said:
These two templates are causing the redefinition problem and it is
clear that keyword "bool" is being resolved as "short".

I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.

- Can anyone give any directions regarding what could cause this
problem?

Look for a header, included before that with "#define bool short".
 
G

Gianni Mariani

lomat said:
I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.

- Can anyone give any directions regarding what could cause this problem?

Get a later version of the compiler. The latest (and best) version is
gcc 3.3.1 and is significantly better than 2.9x .
 
L

lomat

Hello,

While compiling a file, I get following error ....

=================================
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:14
2: redefinition of `struct __type_traits<short int>'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:10
2: previous definition here
=================================


If I open file
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h,
the source code looks like below,
=================================
94 #ifndef __STL_NO_BOOL
95
96 __STL_TEMPLATE_NULL struct __type_traits<bool> {
97 typedef __true_type has_trivial_default_constructor;
98 typedef __true_type has_trivial_copy_constructor;
99 typedef __true_type has_trivial_assignment_operator;
100 typedef __true_type has_trivial_destructor;
101 typedef __true_type is_POD_type;
102 };
103
104 #endif /* __STL_NO_BOOL */
....
<snip>
....

142 __STL_TEMPLATE_NULL struct __type_traits<short> {
143 typedef __true_type has_trivial_default_constructor;
144 typedef __true_type has_trivial_copy_constructor;
145 typedef __true_type has_trivial_assignment_operator;
146 typedef __true_type has_trivial_destructor;
147 typedef __true_type is_POD_type;
148 };
=================================

The macro __STL_NO_BOOL is NOT defined in my environment.

If I pass the file through the precompiler (using command gcc -E <file name,
inc paths etc.>), output shows above two templates as .....
=================================
template<> struct __type_traits< short > {
typedef __true_type has_trivial_default_constructor;
typedef __true_type has_trivial_copy_constructor;
typedef __true_type has_trivial_assignment_operator;
typedef __true_type has_trivial_destructor;
typedef __true_type is_POD_type;
};
....
<snip>
....
template<> struct __type_traits<short> {
typedef __true_type has_trivial_default_constructor;
typedef __true_type has_trivial_copy_constructor;
typedef __true_type has_trivial_assignment_operator;
typedef __true_type has_trivial_destructor;
typedef __true_type is_POD_type;
};
=================================

These two templates are causing the redefinition problem and it is clear
that keyword "bool" is being resolved as "short".

I am using GCC 2.95.3 on RedHat 8.0 on Intel PIII.

- Can anyone give any directions regarding what could cause this problem?

- Secondly, though in my opinion bool is being resolved as short, the error
flagged by compiler says "redefinition of `struct __type_traits<short
int>'". As a result, I am not sure if what I think is incorrect or "short"
is same as "short int"?

Thanks,


Loma
 
L

lomat

Gianni Mariani said:
problem?

Get a later version of the compiler. The latest (and best) version is
gcc 3.3.1 and is significantly better than 2.9x .

Thanks Gianni

I can't use the latest GCC version 3.3, as the name mangling sheme it uses
is different from the 2.95.x scheme.
I tried using 3.3 but then I get zillions of linkage errors as the symbols
from the libraries I use (which are built using 2.95.x) can't be resolved.
The libraries that I use are non-open source (third party) and I can't build
them using 3.3 as I don't have shource.
As a result, I must use 2.95.x. Any suggestions?
 
G

Gianni Mariani

lomat said:
Thanks Gianni

I can't use the latest GCC version 3.3, as the name mangling sheme it uses
is different from the 2.95.x scheme.
I tried using 3.3 but then I get zillions of linkage errors as the symbols
from the libraries I use (which are built using 2.95.x) can't be resolved.
The libraries that I use are non-open source (third party) and I can't build
them using 3.3 as I don't have shource.
As a result, I must use 2.95.x. Any suggestions?

No easy ones.

a) Time to go back to the supplier and get 3.3.1 binaries ?

b) Stick to a subset of C++ that 2.95.x is happy with.

c) Get the functionality from a different source that supplies 3.3.1
binaries.
 
T

tom_usenet

Thanks Gianni

I can't use the latest GCC version 3.3, as the name mangling sheme it uses
is different from the 2.95.x scheme.
I tried using 3.3 but then I get zillions of linkage errors as the symbols
from the libraries I use (which are built using 2.95.x) can't be resolved.
The libraries that I use are non-open source (third party) and I can't build
them using 3.3 as I don't have shource.
As a result, I must use 2.95.x. Any suggestions?

Try adding
#define __STL_NO_BOOL 1
to your project defines.

Tom
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top