Some differences inline functions and macros functions

Too lazy to write, direct links put the answer right

Meaning macros and inline functions

Compared to the normal function, inline function more efficiently, mainly due to an inline function without interrupting the call, save time by copying the code function calls.

We can see from the implementation of an inline function, it only saves time function calls, if the inline function itself takes on the long, save so little time calling does not have much improved, but the function itself is complex, the final executable file corresponding increments than a larger size, and therefore should not be too large inline functions, mainly for the following situations:
1) a call function continually repeated
2) function simply not included for, while, switch and other statements.

Be careful when you realize:
1, keyword inline function definition must be placed together to make the body function inline, just before will have no effect on the function declaration inline.
2, inline function should be defined in the header file. Be sure to define when calling function used is the same, and to ensure that the definition of the function call site compiler is visible.

Comparative macro inline function:
1, compared to the inline function macro, the inline type checking parameters do so in terms of macro inline safer compared.
2, the inline function at run-time debugging, not the macro definition.

 

Guess you like

Origin www.cnblogs.com/zhlabcd/p/11277127.html