Andes Workshop

inline and optimization
Page 1 of 1

Author:  cindy [ Mon Jul 14, 2014 5:24 pm ]
Post subject:  inline and optimization ... 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) ... ic&t=82874
(2) (Chinese page)

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group