Inline Expansion
Hi there
I wonder how inline expansion works exactly.
I''ve an inline function that calls another inline function.
Does the compiler the full expansion on both?
Can one set the level of inline expansion? (e.g. Max 8 expansions). In BCB5, I haven''t found such configuration...
I don''t know asm, so I can''t check my sourcecode, whether the expansion works or not. (Of course I could benchmark).
thanx for your replies.
(Computer && !M$ == Fish && !Bike)
If the both functions are functions that the compiler would inline, then it will inline both and optimize on the inlined code.
For example if I have:
inline int FuncA(int a) { return a; }
inline int FuncB(int b) { return FuncA(-b * b); }
inline int FuncC(int c) { return FuncB(c + c); }
inline int FuncD(int d) { return FuncC(- d); }
and call
int a = FuncD(4);
the compiler will expand through all four function calls (and then replace the whole thing with a -64).
As far as I know you can''t affect how nested the functions will be. And probably shouldn''t, as you might emit code for a function that is expanded elsewhere.
For example if I have:
inline int FuncA(int a) { return a; }
inline int FuncB(int b) { return FuncA(-b * b); }
inline int FuncC(int c) { return FuncB(c + c); }
inline int FuncD(int d) { return FuncC(- d); }
and call
int a = FuncD(4);
the compiler will expand through all four function calls (and then replace the whole thing with a -64).
As far as I know you can''t affect how nested the functions will be. And probably shouldn''t, as you might emit code for a function that is expanded elsewhere.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement