Why? __INLINE Generally, we need to add static
Here's why :
Developers can't decide whether a function is inlined , Developers only have the right to make suggestions , Only the compiler has the right to decide .
below , Let's take a look at a quilt static inline Decorated non inline function :
static __inline int Fake_StaticInline_Add(int n1,int n2,int n3,int n4,int n5)
{
/ Just to get a few more instructions /
n1++;n1++;n1++;n1++;n1++;n1++;n1++;n1++;n1++;n1++;n1++;
return (n1+n2+n3+n4+n5);;}
This function we put in main.c in , And in main Function is called like this :i = Fake_StaticInline_Add(6,6,6,6,6);. Now let's look at his disassembly code :
MOVS r0,#5
MOV r3,r0
MOV r2,r0
MOV r1,r0
STR r0,[sp,#0]
BL Fake_StaticInline_Add
MOV r4,r0
NOP Isn't surprise , No surprise ? This function is actually called , It is not inlined to where it is called . that , Why didn't this function become an inline function ?
I infer that I wrote too many instructions in this function , The compiler determines if it becomes an inline function , It takes up a lot of space , So don't compile it as an inline function .
But do you remember when we put Inline_Add Where is the function ? In a header file . Just imagine , If this Inline_Add Without being compiled as an inline function , By include To multiple source files , It is bound to lead to the problem of repeated definition of functions . therefore , We need to add another keyword static, To avoid this problem .







![[today in history] June 10: Apple II came out; Microsoft acquires gecad; The scientific and technological pioneer who invented the word](/img/0d/9f99eb3dcb73c912987b81fba71890.png)

