473,386 Members | 1,738 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,386 software developers and data experts.

linkage -O3 templates

Hi,

I've got some linking trouble. I've got a project with many template
classes. Everything works fine as long as I do not use -O3 for optimizing.
If I use it, I get some linker error about undefined references. All
methods, the linker misses, are empty member functions of template classes.
So the compiler optimizes them away with -O3, but the linker still needs
them!?!. What can I do about it?

regards,
Alex
Jul 19 '05 #1
3 1300
Alexander Stippler wrote:
Hi,

I've got some linking trouble. I've got a project with many template
classes. Everything works fine as long as I do not use -O3 for optimizing.
If I use it, I get some linker error about undefined references. All
methods, the linker misses, are empty member functions of template
classes. So the compiler optimizes them away with -O3, but the linker
still needs them!?!. What can I do about it?


You say those functions are empty - so why do they exist? Apart from
trimming pointless code your other option seems to be to look at the GCC
man page and enable the individual optimisations that would be done by -O3
minus the one that removes empty functions.

--
The generation of random numbers is too important
to be left to chance. -- Robert R. Coveyou

Jul 19 '05 #2
Jacques Labuschagne wrote:
You say those functions are empty - so why do they exist? Apart from
trimming pointless code your other option seems to be to look at the GCC
man page and enable the individual optimisations that would be done by -O3
minus the one that removes empty functions.


Sometimes one needs empty functions. Just think of constructors, which would
not exist otherwise (as soon as you have another constructor). And I'm not
looking for a workaround. I'm looking for a solution.

regards,
alex
Jul 19 '05 #3
Alexander Stippler wrote:
Sometimes one needs empty functions. Just think of constructors, which would
not exist otherwise (as soon as you have another constructor). And I'm not
looking for a workaround. I'm looking for a solution.


It could be a bug in the optimizer, have you tried to compile it with a
different version of the compiler? (2.95, 3.0, 3.1, ...)

Hmm, you probably have to ask this on a gcc mailing list. Maybe they can
help you.

Christoph

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: qazmlp | last post by:
const has internal linkage in C++, but external linkage in C. Am I right ? But, linker reports multiply-defined error if the following header is included in multiple .cpp files. //...
4
by: Tron Thomas | last post by:
I have read that anonymous namespaces are preferred in C++ over declaring global statics because the namespace can hide information from other translation units and at the same time provide...
20
by: Grumble | last post by:
Hello everyone, As far as I understand, the 'inline' keyword is a hint for the compiler to consider the function in question as a candidate for inlining, yes? What happens when a function with...
22
by: Ian | last post by:
The title says it all. I can see the case where a function is to be called directly from C, the name mangling will stuff this up. But I can't see a reason why a template function can't be...
10
by: Mark A. Gibbs | last post by:
I have a question about mixing C and C++. In a C++ translation unit, I want to define a function with internal linkage and C calling convention. Here's a sample of what I want to do: //...
3
by: al.cpwn | last post by:
do static and inline functions or members have internal linkage? I have been reading this newsgroup on google and found conflicting ideas. Can someone please help me understand why in some places...
3
by: martinbriefcase | last post by:
Compiling a program using ACE + MSVC++8, got lots of errors and some are listed as below: Error 2 error C2894: templates cannot be declared to have 'C' linkage c:\program files\microsoft visual...
11
by: jakester | last post by:
I am using Visual C++ 2007 to build the code below. I keep getting linkage error. Could someone please tell me what I am doing wrong? The code works until I start using namespace for my objects. ...
12
by: Taras_96 | last post by:
Hi everyone, AFAIK external linkage allows you to refer to variables/functions outside of the current translation unit. A variable in an unnamed namespace is similar to declaring a static...
4
by: Immortal_Nephi | last post by:
You have written several global functions inside header code. Then, you create either static library or dynamic linked library. All global functions can be reuseable to the main() function when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.