473,725 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:1 4
2: redefinition of `struct __type_traits<s hort int>'
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:1 0
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<b ool> {
97 typedef __true_type has_trivial_def ault_constructo r;
98 typedef __true_type has_trivial_cop y_constructor;
99 typedef __true_type has_trivial_ass ignment_operato r;
100 typedef __true_type has_trivial_des tructor;
101 typedef __true_type is_POD_type;
102 };
103
104 #endif /* __STL_NO_BOOL */
....
<snip>
....

142 __STL_TEMPLATE_ NULL struct __type_traits<s hort> {
143 typedef __true_type has_trivial_def ault_constructo r;
144 typedef __true_type has_trivial_cop y_constructor;
145 typedef __true_type has_trivial_ass ignment_operato r;
146 typedef __true_type has_trivial_des tructor;
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_def ault_constructo r;
typedef __true_type has_trivial_cop y_constructor;
typedef __true_type has_trivial_ass ignment_operato r;
typedef __true_type has_trivial_des tructor;
typedef __true_type is_POD_type;
};
....
<snip>
....
template<> struct __type_traits<s hort> {
typedef __true_type has_trivial_def ault_constructo r;
typedef __true_type has_trivial_cop y_constructor;
typedef __true_type has_trivial_ass ignment_operato r;
typedef __true_type has_trivial_des tructor;
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 "redefiniti on of `struct __type_traits<s hort
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 5005
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*******@mari ani.ws> wrote in message
news:bk******** @dispatch.conce ntric.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*******@mari ani.ws> wrote in message
news:bk******** @dispatch.conce ntric.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.c om> wrote:

"Gianni Mariani" <gi*******@mari ani.ws> wrote in message
news:bk******* *@dispatch.conc entric.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
6740
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) template<class X> void myfunc(X par1) { } (in derived class) template<class X>
0
1954
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 the resulting functions or classes are identical, without causing any errors. Or so I thought. But a few days ago, I added a couple of new template functions to one of my personal library modules, and I got this linker error message (from...
1
1989
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 personal library headers. My library, librh.a, has these objects: rhutil.o rhdir.o rhmath.o rhbitmap.o and matching headers: rhutil.h rhdir.h rhmath.h rhbitmap.h
2
2800
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 library headers. > > > > My library, librh.a > > Linking is not defined by C++ .
1
3515
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). That application is built by one company and its usage is to show functionality of their static libraries. Now I created dynamic link library CoreLibrary and I want to integrate it into this example. CoreLibrary worked properly with win32...
0
1349
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 of template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
0
1989
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 methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
1
2776
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 template methods along with their declarations in the header file. Well, there are also other files in the project, which include this header file as well, which all gets compiled, linked and tested well. #ifndef __ATT_H__
1
2226
by: Ioannis Gyftos | last post by:
Hello, First the code :) /////////////////////////////////////////////////////////////////////////////////// // in another header file namespace LJC{
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8096
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.