473,769 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to know the inline-function was implemented the inline way or normal way?

Hello All,

Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
Thanks and Regards,
Yogesh Joshi
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 14 '06 #1
7 3171
yp*********@ind iatimes.com wrote:
Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
A function itself is just a collection of tokens. What is made inline
are the _calls_ to that function.
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
Not portably.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 14 '06 #2
yp*********@ind iatimes.com wrote:
Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
The only way I can think to do that at all would be to read the
compiler-generated assembly code. As Victor said, there's definitely
no way to portably do it at runtime. A better question is why do you
care? Sometimes it's better if a function is *not* inlined. That's
why compilers are allowed to treat inline as a suggestion.

Kristo
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 15 '06 #3
yp*********@ind iatimes.com wrote:
Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
Not in any portable way. In any case, why do you need to find out at
_runtime_?

If you just wanted to find out at compile time, there are several
(nonportable) things you could do. First, many compilers will output
the assembly version of your compiled program, so you can manually
check. Of course, you would have to check again every time you
recompiled the program, since any changes could affect whether a
particualar inline request was honored by the compiler.

Second, some compilers will emit a warning if they fail to honor an
inline request. For example, in gcc, the "-Winline" command option
will emit a warning if the compiler does not inline a function that was
declared inline.

But that brings me back to my original question - why do you want to
find out at _runtime_?

Best regards,

Tom
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 15 '06 #4
yp*********@ind iatimes.com wrote:
Inline before a function definition is just a request to the
compiler to make the function inline.
The compiler may or maynot make it inline..
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
No. The question has no real meaning; a C++ program defines a
specific semantic, not a sequence of machine instructions. A
compiler may inline functions not declared inline (many do), not
inline a function declared inline, and generally not be
consistent about what it does---the same function may be
generated inline at one call site, and not at another. (At
least one compiler ignores the inline entirely, and uses
profiling information to decide where it inlines a function.)

--
James Kanze ka*********@neu f.fr
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 15 '06 #5
yp*********@ind iatimes.com wrote:
Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
Right.
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
First question: Why would you need to know? If your program depends on
this, then something's pretty wrong with your design.

If this is part of your optimization/profiling strategy:

A short answer would be that you would need to check the
assembly/machine code output of the compiler. There's no portable way of
checking whether the function got inlined or not.

Another answer would be to measure the running time of the program. If
it got faster, then the strategy of the compiler optimizing your code
improved by marking the function as "inline". Whether it then inlined
the code, or did something else, shouldn't matter - as long as the code
got faster. What else do you want? (-;

That said, I've observed programs that got slower by marking a function
as "inline".

So long,
Thomas

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 15 '06 #6

yp*********@ind iatimes.com wrote:
Hello All,

Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
My question is ..is there any way by which I can find at runtime
whether the particular function which is marked as inline,is made
inline or is treated like other function by the compiler ?
I would consult your C++ compiler's documentation to answer the
question as it pertains to your situation. Some C++ compilers can be
configured to issue a warning whenever a function declared inline is
not inlined for whatever reason (for example, the -Winline command line
option for the gcc compiler). As others have noted, the set of inlined
function calls in a program can be highly variable - therefore creating
dependencies on the inlined state of a particular function call is
probably not a recipe for stable development.

Greg
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 17 '06 #7
yp*********@ind iatimes.com wrote:
Hello All,

Inline before a function definition is just a request to the compiler
to make the function inline.
The compiler may or maynot make it inline..
Or only inline half a function. Or inline the entire function in some
places,
yet not inline it at all in others. Or not inline it, but pass the
parameters
in a different fashion. So "the answer" is not a single boolean answer.

HTH,
Michiel Salters
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.m oderated. First time posters: Do this! ]

Jul 18 '06 #8

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

Similar topics

5
2320
by: Michele | last post by:
What does the CIO need to know about Sequel Server administration?
4
1846
by: Support | last post by:
Hi, I want to know if I have changed a few records in my database using update / insert / delete methods, how can i later know which rows have been changed or modified ? I know the ExecuteNonQuery method which can give me the "number" of modified rows, but which rows are changed how do I know ? Any ideas ?
41
6091
by: Nitin Bhardwaj | last post by:
Hi all, I wanted to know whether the stack in a C program is growing upwards or downwards.So I wrote a little code to see that.Please guide me as to whether this code is correct in telling this ? #include <stdio.h> int main(void) {
3
3578
by: Chris | last post by:
Wait.. before you flame.. If someone can program in Java, or Javascript, or C, or (insert your language here that uses basically the same syntax as C#), and that person knew how to program in VB.NET (meaning they understand the .NET Framwork, how to use the IDE, the classes and components available, etc.) then would they really need to "learn" C#? I have done some coding in C#, I wrote an entire app in it, but I use VB.NET whe...
2
1524
by: M | last post by:
I'm new to .NET/C# and I've been programming C# for a month or so now. I'm not a C++ programmer, but I like knowing how stuff works, so I started reading a C++/COM/ATL book. I got about halfway through it before I started doing C#, and now I'm wondering why I should ever learn COM/ATL. Any reasons for me to tackle that hog? In other words, why should I ever write new code in COM/C++? Are there specific reasons I should know this
7
1394
by: Moti | last post by:
Hi all I use C# to read messages from msmq queue. When I knew that it is writing in c# I can read it. When I knew that it is writing in VB6 I can read it. How can I know in which format the message is writing? Moti.
6
6939
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know that either the sub did a redirect or a specific value was specified in the URL. If neither a redirect was done and a certain value was
0
1112
by: Nhanvu | last post by:
VB.NET Do you know how to know the color of a point(x,y)? And how to know the name of a color if you know its (r, g, b)? I have to check the color of a point, and I don't know how to do! Can anybody help me, plzzz!
10
2099
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I don't somehow share the code. So, I copy the folder P1 is in, change the new folder name, and is VS2005 to change all occurrences of P1's name tp P2's name.
102
5160
by: BoogieWithStu22 | last post by:
I am running into a problem with a web page I have created when viewing it in IE6 on some machines. The page has a database lookup. The user enters an account name or number and clicks a lookup button. This hits an AS400 database looks for matches and returns a dataset that is used to populate a datagrid. The user then selects one of the entries from the list, this entry is used to populate a couple of textboxes on the page and a couple...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
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
10047
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...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
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
7410
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
6674
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
5304
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...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.