Daily C language inline FunctionEvery day, I picked up a C-language shell, which grew up and formed thousands of miles.
Today's shells: the original intention and usage of inline functions in C Language
Purpose: introduce inline functions to reduce the overhead of function calls.Usage:Add the qualifier inline before the function return value: for exampleInlineintfunction (int n );The compiler generates a copy of the function code at an appropriate position in the source file to avoid function calls. From the function perspective, although macros can reduce the overhead of function calling, macros have inherent defects that cannot be avoided.Advantage: inline functions expand like macros, And the execution speed is very fast.Limitations:1. Suggestion: defining inline functions is actually a "suggestion" for the compiler, which may be rejected by the compiler.2. Small functions: If the inline function has a large amount of code, the compiler is almost impossible to adopt the inline "suggestion ".3. Restrictions: inline functions cannot contain statements such as loops.
Have a nice day!