473,463 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inline-code

hi,

i have a simple question for inline code :

class x {
private:
int xx;
public:
int getXX(void){ return x; }
};

is the same like :

class x {
private:
int xx;
public:
int getXX( void );
};

inline int x::getXX( void )
{
return x;
}

or is a differenz between these code ?

thanks
Stephan
Jul 22 '05 #1
10 1532
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,

i have a simple question for inline code :
int getXX(void){ return x; } inline int x::getXX( void ) or is a differenz between these code ?


There _may_ be a difference. The first kind of inlining is done when you
compile the code #include-ing the header file. The second is a request to
do inlining at the linking stage. Which it may or may not do.

Read your compiler and linkers documentation.

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up

Jul 22 '05 #2
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,

i have a simple question for inline code :
[ snip inclass-definition and outclass-inline-definition ]
or is a differenz between these code ?


No, they are equivalent.

HTH,
M4

Jul 22 '05 #3

"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,

i have a simple question for inline code :
[ snip inclass-definition and outclass-inline-definition ]
or is a differenz between these code ?


No, they are equivalent.


I don't think that's correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It's possible that
the compiler/linker may *not* inline it. Isn't that correct?

HTH,
M4

Jul 22 '05 #4

"Howard" <al*****@hotmail.com> wrote in message
news:bu********@dispatch.concentric.net...

"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,

i have a simple question for inline code :


[ snip inclass-definition and outclass-inline-definition ]
or is a differenz between these code ?


No, they are equivalent.


I don't think that's correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It's possible that
the compiler/linker may *not* inline it. Isn't that correct?


But that is true for either case.
They are equivalent.
HTH,
M4


Jul 22 '05 #5

"Nils Petter Vaskinn" <no@spam.for.me.invalid> wrote in message
news:pa****************************@spam.for.me.in valid...
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,

i have a simple question for inline code :
int getXX(void){ return x; }

inline int x::getXX( void )

or is a differenz between these code ?


There _may_ be a difference. The first kind of inlining is done when you
compile the code #include-ing the header file. The second is a request to
do inlining at the linking stage. Which it may or may not do.


There isn't. And it isn't. But it is true that it mat not do the inlining.
In particular the compiler is highly likely to inline nothing at all if you
compile
for debugging.

(You may be getting confused with extern templates)
Read your compiler and linkers documentation.

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up

Jul 22 '05 #6
On Mon, 19 Jan 2004 13:27:38 -0500, Howard wrote:

"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
> hi,
>
> i have a simple question for inline code :


[ snip inclass-definition and outclass-inline-definition ]
> or is a differenz between these code ?


No, they are equivalent.


I don't think that's correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It's possible that
the compiler/linker may *not* inline it. Isn't that correct?


That is right, but the same goes for the inclass definition, so they are
equivalent. (BTW I've yet to see a linker that can do inlining, although
it makes sense).

M4
Jul 22 '05 #7
Howard wrote:
"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
> hi,
>
> i have a simple question for inline code :


[ snip inclass-definition and outclass-inline-definition ]
> or is a differenz between these code ?


No, they are equivalent.


I don't think that's correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It's possible that
the compiler/linker may *not* inline it. Isn't that correct?
...


Inlining is always a suggestion regardless of how the function is
declared - outside the class definition with explicit 'inline' keyword
or inside the class definition. Both variants are indeed equivalent.

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #8

"Andrey Tarasevich" <an**************@hotmail.com> wrote in message
news:10*************@news.supernews.com...

Inlining is always a suggestion regardless of how the function is
declared - outside the class definition with explicit 'inline' keyword
or inside the class definition. Both variants are indeed equivalent.

--
Best regards,
Andrey Tarasevich


Ok, thanks. I learn something new here every day! :-)

-Howard
Jul 22 '05 #9

"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
[SNIP]
I don't think that's correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It's possible that the compiler/linker may *not* inline it. Isn't that correct?


That is right, but the same goes for the inclass definition, so they are
equivalent. (BTW I've yet to see a linker that can do inlining, although
it makes sense).

M4


AFAIK SGI's and IBM's Visual Age compiler are/were able to do such things.
Furthermore there are some other inhouse compilers that can do that job,
although it is still not very common.

Chris
Jul 22 '05 #10
Chris Theis wrote:
> I don't think that's correct. As I understand it, the inline keyword is
> actually just a suggestion/request to inline the code. It's possible that > the compiler/linker may *not* inline it. Isn't that correct?


That is right, but the same goes for the inclass definition, so they are
equivalent. (BTW I've yet to see a linker that can do inlining, although
it makes sense).

M4


AFAIK SGI's and IBM's Visual Age compiler are/were able to do such things.
Furthermore there are some other inhouse compilers that can do that job,
although it is still not very common.
...


This capability is not really needed for standard C++ inlining (as it is
defined in C++ language specification), since the language specification
requires source code of inline function to be available in every
translation unit where the function is used.

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #11

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

Similar topics

13
by: A | last post by:
Hi, I'm having problems completing a project in C++. I have been using inline functions in some of my header files. I have only done so for simple functions that only have 1 statement (eg....
46
by: DJ WIce | last post by:
Hi all, I did make a script/css thing to replace the contextmenu on the website with a new one: http://www.djwice.com/contextmenu.html It works nice in MSIE, but on Netscape (and probable...
23
by: Mat | last post by:
<div id="container"> <div id="main"> <div id="header"> <p class="Address">123 Fake Street, </p> <p class="City">Crazy City, </p> <p class="Province">Ontario </p> <p class="PostalCode">H0H...
47
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
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...
5
by: Tony Johansson | last post by:
Hello experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that sound strange. Here is the whole section: It says" Because...
6
by: ste.paoletti | last post by:
hi, I have read that browsers support block element inside inline element but the css is not valid. Someone can tell me more about? What do you think? Thanks.
7
by: Wu Shaohua | last post by:
Hi Guys, 1. As we know usually we should not define a constructor as inline. I also learned if we define a member function inside the class this member function will be automatically be...
5
by: Barry | last post by:
Hi, group First, I write same cases I've already known, I don't concern that specific compiler really do inline or not. Please check them if they are right, and add the cases I miss 1. //...
2
by: Barry | last post by:
Hi, group First, I write same cases I've already known, I don't concern that specific compiler really do inline or not. Please check them if they are right, and add the cases I miss 1. //...
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
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...
1
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...
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
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.