Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Function inlining (http://www.velocityreviews.com/forums/t440890-function-inlining.html)

Ian 01-14-2006 09:07 PM

Function inlining
 
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.

Mark McIntyre 01-14-2006 10:19 PM

Re: Function inlining
 
On Sun, 15 Jan 2006 10:07:50 +1300, in comp.lang.c , Ian
<ian-news@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 =----

Jack Klein 01-15-2006 03:57 AM

Re: Function inlining
 
On Sun, 15 Jan 2006 10:07:50 +1300, Ian <ian-news@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

Ian Collins 01-15-2006 05:49 AM

Re: Function inlining
 
Jack Klein wrote:
> On Sun, 15 Jan 2006 10:07:50 +1300, Ian <ian-news@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.


All times are GMT. The time now is 10:22 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.