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

Function inlining

Ian
This is partly related to the kernel C/C++ thread, one thing I'm not
sure about with modern C compiler is how aggressively they inline
trivial functions as an optimisation.

A C++ compiler will be fairly aggressive in this area, so it is
generally safe to assume that short functions will get inlined away as
this tends to improve both code size and execution speed.

Do modern C compilers do the same?

Cheers,

Ian.
Jan 14 '06 #1
3 1586
On Sun, 15 Jan 2006 10:07:50 +1300, in comp.lang.c , Ian
<ia******@hotmail.com> wrote:

(of optimisation)
Do modern C compilers do the same?


This is not topical here, since it depends on the compiler not on the
language. For an authorative answer you'd need to ask in groups
specialising in various compilers. Offhand however I'd simply point
out that most compiler suites these days contain C and C++ tools from
the same source and it'd be pretty bizarre not to perform similar
optimizations in your two offerings.
Mark McIntyre
--

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jan 14 '06 #2
On Sun, 15 Jan 2006 10:07:50 +1300, Ian <ia******@hotmail.com> wrote
in comp.lang.c:
This is partly related to the kernel C/C++ thread, one thing I'm not
sure about with modern C compiler is how aggressively they inline
trivial functions as an optimisation.

A C++ compiler will be fairly aggressive in this area, so it is
generally safe to assume that short functions will get inlined away as
this tends to improve both code size and execution speed.

Do modern C compilers do the same?


First, please use a proper signature delimiter, like mine at the
bottom. It consists of "-- ". Most newsreaders recognize this and
provide proper handling automatically.

Second, what is your definition of "modern C compilers"? Optimization
is both inherently implementation specific, and not defined by the C
standard. If you want to know about the behavior of specific
compilers, as in their compiler specific support groups or try them
yourself.

Note that compilers that support the 1999 or later versions of the C
standard recognize the inline keyword to specifically suggest to the
compiler that you want a particular function inlined. Just as with
the register keyword, the compiler is free to ignore your request.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 15 '06 #3
Jack Klein wrote:
On Sun, 15 Jan 2006 10:07:50 +1300, Ian <ia******@hotmail.com> wrote
in comp.lang.c:

This is partly related to the kernel C/C++ thread, one thing I'm not
sure about with modern C compiler is how aggressively they inline
trivial functions as an optimisation.

A C++ compiler will be fairly aggressive in this area, so it is
generally safe to assume that short functions will get inlined away as
this tends to improve both code size and execution speed.

Do modern C compilers do the same?

First, please use a proper signature delimiter, like mine at the
bottom. It consists of "-- ". Most newsreaders recognize this and
provide proper handling automatically.

OK, done.
Second, what is your definition of "modern C compilers"? Optimization
is both inherently implementation specific, and not defined by the C
standard. If you want to know about the behavior of specific
compilers, as in their compiler specific support groups or try them
yourself.

Note that compilers that support the 1999 or later versions of the C
standard recognize the inline keyword to specifically suggest to the
compiler that you want a particular function inlined. Just as with
the register keyword, the compiler is free to ignore your request.

It's been a while since I've studied compiler output on embedded
systems, but when I was working in this area, we had to resort to macros
rather than short functions because our compiler didn't inline trivial
functions.

I was simply curious about the current state of the art.

--
Ian Collins.
Jan 15 '06 #4

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

Similar topics

6
by: glen_stark | last post by:
Hi. I'm just curious if there any warnings or caveats or whatever to be aware of when inlining function object calls? If the answer is no, they inline just like everything else, that's good...
8
by: Mat Booth | last post by:
If I call an inline member function through a member function pointer, will that function be inlined? I imagine it wouldn't because the function that's pointed to isn't known until run-time, is...
5
by: publictom | last post by:
I just happened to read item 47, "Control Flow", in Exceptional C++ by Herb Sutter (which is based on Guru of the Week 12), just after reading item 33, "Use Inlining Judiciously", in Effective C++...
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
4
by: thinktwice | last post by:
i have just made a test project :(win32 console) //file : func.h #ifndef _FUNC_H_ #define _FUNC_H_ void func1() { return; };
12
by: Tomás | last post by:
The common persuasion is: Big function -- leave it outline. Small function -- make it inline. In code I'm writing at the moment, I have a fairly long function, so it wouldn't cross my...
15
by: Lloyd Dupont | last post by:
I have some code which looks like that: public CornerStyle RectCornerMode { get { return this.GetValue<CornerStyle>(); } set { this.SetValue<CornerStyle>(value); } }
45
by: madhawi | last post by:
Is it better to use a macro or a function?
8
by: Yakov | last post by:
I'd like a tool that performed inlining of function bodies of which do not appear in the .h file. Really. gcc on Linux. Yakov
10
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.