Using inline to modify the declaration or implementation of a function can make it an inline function
It is recommended to add inine modification to both declaration and implementation
Features:
- The compiler will expand the function call directly into the function body code
- Can reduce the overhead of function calls
- Will increase code size
Notice:
- Try not to inline functions longer than 10 lines of code
- Even if some functions are declared inline, they may not be inlined by the compiler, such as recursive functions
When to use inline functions?
- Function code size is small
- frequently called functions
Inline functions and macros:
- Both inline functions and macros can reduce the overhead of function calls
- Compared with macros, inline functions have more syntax detection and function features