473,651 Members | 3,004 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 1603
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************ *********@i42g2 000cwa.googlegr oups.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
6550
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. accessor and mutator methods to access private data members). I would like to know if there are any issues with using inline functions that may have attributed to my errors before I start separting them out into "outline functions". Regards
4
4079
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 portable? Cristian
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 read many authors (and it's my belief, too) who discourage the use of the 'inline' keyword, because: - The 'inline' word only advice the compiler about wich functions should be expanded, but not force it to expand them. Also, the compiler can...
6
2447
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 function's definition (the part between the {...}) be placed in a header file. If you put the inline function's definition into a .cpp file, and if it is called from some other .cpp file, you'll get an "unresolved external" error from the linker. " Why...
2
2690
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 same module but not if it is called from a second module i.e. extern inline. For example (extremely simplified), inline void Bob(void)
2
3847
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
2122
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
3767
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 common meanings: static as in "statically allocated" as opposed to on the stack or on the free store and static as in "with restricted visibility" as opposed to with external linkage. For member functions, static has the second meaning."
6
4056
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 inlined because it uses variable argument lists variadic.c: In function ‘vf’: variadic.c:12: warning: inlining failed in call to ‘fv’: function not inlinable variadic.c:27: warning: called from here
0
8277
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8465
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
8581
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
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
5612
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
4144
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
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
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 we have to send another system
2
1588
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.