473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Template redefinition problem

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
5 4974
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
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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Massimiliano Alberti | last post by:
Can I specialize a template function in a subclass without overriding it? (the main template function is defined in a base class). Now I'm doing something like that: (in base class)...
0
by: Robbie Hatley | last post by:
I'd always thougth that a C++ compiler/linker should be able to instantiate a template in mulitple places (say, in two different translation units), even using the same template parameters so that...
1
by: Robbie Hatley | last post by:
I asked about this yesterday, but no one bit. So I'll ask again. I can be a persistant cuss. :-) I ran into a problem a few days ago when I added a couple of template functions to one of my...
2
by: Robbie Hatley | last post by:
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote: > Robbie Hatley wrote: > > > > I ran into a problem a few days ago when I added a couple of > > template functions to one of my personal...
1
by: Alex | last post by:
Hello all, I have a very stupid problem that is driving me crazy...so plz if anyone ever saw this, I would like him to help me :) I have static MFC application in MSVC++ 6.0 (named Example)....
0
by: anto.anish | last post by:
Hi , Since, i did not want to write all instantiations in Source file of all template methods for various different datatypes that my client might use, Instead, i choose to write implementation...
0
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
1
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.