473,396 Members | 1,780 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.

linking instanciated inline functions

I know that declaring a function as inline does not imply the function
will actually be inlined (e.g. recursive functions, etc...).

In that case, where would the function be instanciated?
My guess is that it would be instanciated in the compilation unit that
uses it. But in this case, several compilation units that use the same
inline function would mean that the linker has to deal with several
instances of the same function: shouldn't the linker fail on this?

So:
- are the linkers required to "optimize" and remove duplicate instances
of a function?
- do compilation units that require instanciating an inline function do
it only locally, not exposing the instance to the linker?

I actually never faced any such problem, as my compiler/linker handles
it somehow, but I was simply wondering what was going on really...
Jan 13 '07 #1
1 1440
Sylvain Audi wrote:
I know that declaring a function as inline does not imply the function
will actually be inlined (e.g. recursive functions, etc...).

In that case, where would the function be instanciated?
My guess is that it would be instanciated in the compilation unit that
uses it. But in this case, several compilation units that use the same
inline function would mean that the linker has to deal with several
instances of the same function: shouldn't the linker fail on this?

So:
- are the linkers required to "optimize" and remove duplicate instances
of a function?
The C++ Standard requires at most one copy in the entire program of a
non-static inline function, so in effect, yes.
- do compilation units that require instanciating an inline function do
it only locally, not exposing the instance to the linker?
Some compilers may do this to improve build times, but it isn't standard
conforming. I tend to default to this option with my compiler for
development builds where compiling with debug disables function inlining.

--
Ian Collins.
Jan 13 '07 #2

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

Similar topics

11
by: Georg Teichtmeister | last post by:
Hello! We are developing a math - library for realtime applications and want to use some given mathlibraries as base(ipp, MTL, .. ). Our library is a wrapper for those and you should be able to...
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
3
by: Steven T. Hatton | last post by:
Sorry about the big code dump. I tried to get it down to the minimum required to demonstrate the problem. Although this is all done with GNU, I believe the problem I'm having may be more general. ...
21
by: Rubén Campos | last post by:
I haven't found any previous message related to what I'm going to ask here, but accept my anticipated excuses if I'm wrong. I want to ask about the real usefulness of the 'inline' keyword. I've...
6
by: pookiebearbottom | last post by:
Let's say I have headers Sal.h with this class class Sal { public: int doit() { return 1;} }; now I know that the compilier can choose NOT to inline this function. So if I include this in...
0
by: capes | last post by:
have functions in my cell model calling CVODE for each time step. When I build the application I get a number of link errors: \cardiacsimulator.o Release\ccardiaccell.o Release\ccelldata.o...
7
by: bajichuan | last post by:
Hello! I have the world's strangest linking error, and I'm hoping that someone can help me sort it out. I recently installed and compiled a library called LinBox without a problem. I have an...
5
by: ciccio | last post by:
Hi, I have a problem with my code that the compiler does not find any inline functions which are static. The simple code example is written below, this is what the compiler throws at me. ]...
1
by: arjor | last post by:
hey guys When i try to make the following mutating method inline i get the following error: //method inline void vertex::setValue(int new_value) throw() { value_ = new_value; } error...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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.