No-one has really noted the drawbacks of inline.
Inline functions aren't always a good thing. They can indeed make the generated code faster by removing a few instructions, namely a couple of
push and
pops, but they also increase executable size. They also can make things slower. If you had this function
1 2 3 4 5 6
|
inline void inline_function(void) {
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p;
float q, r, s, t, u, v, w, x, y, z;
struct myStruct myObject;
char* myCString;
}
|
(pretend I initialized those variables), you definitely wouldn't inline that. Why? Look how many variables it allocates on the stack. That would slow things down rather than speed them up, not to mention waste memory.
OK, so in practice you usually won't have 30 variables on the stack in a single function, but you might.
Bare in mind that sometimes inlining code can actually make executable sizes smaller.
I would say that as a rule of thumb, try only to inline functions that have 3-8 lines of code in them, or which you only call once or twice. That can help to speed up your code and maybe even make your executable smaller.
Like Bazzy said, though: inline is just a
hint, not an instruction. The compiler ultimately decides.