Andes Workshop

It is currently Thu Mar 28, 2024 8:19 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: inline and optimization
PostPosted: Mon Jul 14, 2014 5:24 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
https://gcc.gnu.org/onlinedocs/gcc-4.1. ... nline.html

5.33 An Inline Function is As Fast As a Macro

By declaring a function inline, you can direct GCC to integrate that function's code into the code for its callers. This makes execution faster by eliminating the function-call overhead; in addition, if any of the actual argument values are constant, their known values may permit simplifications at compile time so that not all of the inline function's code needs to be included. The effect on code size is less predictable; object code may be larger or smaller with function inlining, depending on the particular case. Inlining of functions is an optimization and it really “works” only in optimizing compilation. If you don't use -O, no function is really inline.

....

GCC does not inline any functions when not optimizing unless you specify the `always_inline' attribute for the function, like this:

/* Prototype. */
inline void foo (const char) __attribute__((always_inline));

Reference discussion
(1) http://www.avrfreaks.net/index.php?name ... ic&t=82874
(2) http://blog.roodo.com/rocksaying/archives/2139426.html (Chinese page)


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group