473,503 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do inline functions have a valid code segment

Hi Everybody,

Suppose i have a function like this
class xx{
int func();
};

main(){
xx x1;
x1.func();
}

Then func() goes into the code segment . pl correct me if i'm wrong .

However if i make it inline like this

class xx{
inline int func();
};

then c++ compiler doc says that fuc() is expanded inline where its
called at x1.func() (something very similar to macros do in c) .
ofcourse the decision to make it inline or not rests with the compiler
based on optimization modes

So if func() would be expanded at the place where its called then does
it makes sense to say that inline functions do not have data segment ??
Please let me know

My thanks in advance .

Thanks
Ranjay

Aug 24 '06 #1
3 1589
Ranjay wrote:
Then func() goes into the code segment . pl correct me if i'm wrong .
This is platform specific terminology. The language itself isn't
concerned with segments. But on platforms I know of, yes.
So if func() would be expanded at the place where its called then does
it makes sense to say that inline functions do not have data segment ??
Did you mean code segment? If yes, then no. It will be a code segment
again, it will just be within the calling function instead of being a
function on it's own.

Jens
Aug 24 '06 #2
Ranjay wrote:
Hi Everybody,

Suppose i have a function like this
class xx{
int func();
};

main(){
xx x1;
x1.func();
}

Then func() goes into the code segment . pl correct me if i'm wrong .
You're wrong. The function goes wherever the compiler thinks it should
go.
The only two requirements are 1. it can be called (by xx and friends)
and
2. when called it does the right thing.

And of course the "code segment" is not even present on all CPUs.

HTH,
Michiel Salters

Aug 24 '06 #3
In article <11*********************@i42g2000cwa.googlegroups. com>,
Ranjay <ra******@gmail.comwrote:
>Suppose i have a function like this
class xx{
int func();
};

main(){
xx x1;
x1.func();
}

Then func() goes into the code segment . pl correct me if i'm wrong .

However if i make it inline like this

class xx{
inline int func();
};

then c++ compiler doc says that fuc() is expanded inline where its
called at x1.func() (something very similar to macros do in c) .
ofcourse the decision to make it inline or not rests with the compiler
based on optimization modes

So if func() would be expanded at the place where its called then does
it makes sense to say that inline functions do not have data segment ??
I'm not sure I quite understand your question, but I'll wager a guess
at what you mean: It get put into the segement of where it is expanded --
that is is gets assumed -- whether that be a local block or function
(or elsewhere) is up to the implementation. Also, notions such as
"code segment" are platform specific so also up to the implementation.
If this is not what you mean, please reelaborate in a post.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 24 '06 #4

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

Similar topics

13
6526
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....
4
4070
by: Cristian Tota | last post by:
I am programming Visual C++ 6.0, using inline asm. MSDN says that code with inline asm is not fully portable to other hardware platforms. What does this reffer to? On what platforms isn't the code...
21
746
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
2436
by: John Ratliff | last post by:
I was reading the C++ FAQ Lite about inline functions, and it says the following (http://www.parashift.com/c++-faq-lite/inline-functions.html#faq-9.7) " It's usually imperative that the...
2
2679
by: evan | last post by:
Hi, I've got an easy one... I need to inline a few functions from one module to another. By looking at the compiled code I can see that the function is inlined if it is called from within the...
2
3837
by: Amal P | last post by:
Hi, This is the program that i made to test the usage of inline function. I am using vc 6.0 compiler. Please see the below program. int NonInline( int a, int b ) { return ( a b )? a: b; }
9
2109
by: Martin Wells | last post by:
Is there anything like __inline_is_supported to indicate whether a certain C compiler supports inline? I'm writing my code as fully portable C89, but I want to use inline. Martin
2
3762
by: Nagrik | last post by:
Dear Group, The book of Bjarne Stroustrup in chapter 5.4.4 says the following "The word static is one of the most overused words in C and C++. For static data members it has both of the...
6
4043
by: Laurent Deniau | last post by:
When I compile the code below with gcc -std=c99 -W -Wall -pedantic -O3 -Winline, it reports the following: variadic.c: In function ‘fv’: variadic.c:12: warning: function ‘fv’ can never be...
0
7192
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
7261
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,...
1
6974
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
7445
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
5559
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,...
1
4991
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...
0
1492
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 ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
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...

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.