By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,141 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,141 IT Pros & Developers. It's quick & easy.

Template redefinition problem

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
lomat wrote:

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 .

Jul 19 '05 #2

P: n/a
lomat wrote:
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".

--
Attila aka WW
Jul 19 '05 #3

P: n/a

"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bk********@dispatch.concentric.net...
lomat wrote:

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 .


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?
Jul 19 '05 #4

P: n/a
lomat wrote:
"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bk********@dispatch.concentric.net...
lomat wrote:

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 .

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.

Jul 19 '05 #5

P: n/a
On Mon, 22 Sep 2003 21:05:23 +0530, "lomat" <at****@ideas.com> wrote:

"Gianni Mariani" <gi*******@mariani.ws> wrote in message
news:bk********@dispatch.concentric.net...
lomat wrote:
>
> 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 .


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
Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.