Marking a C function as inline1 specifies that the compiler should debug the function as if it were a regular function yet compile it as if it were a macro. You get all speed benefits of a macro with all the type safety of functions!
It is probably best to only mark small functions as inline because they significantly increase the size of a program. On the other hand, Gruime points out that marking a function as inline will preserve stack space when it is called. If you try and make a really complex function inline, the compiler will ignore you. According to Benjamin Quintero's Guide to Inline Functions the necessary conditions for declaring a function inline are:
- time critical
- called often
- "respectfully" small
Inline functions are standard in ISO C99 and are supported in current versions of gcc and all major C++ compilers. (Thanks tftv256)
1: I am not sure of the exact placement within C's syntactic structure, but most people will be happy knowing that the
inline keyword goes before the return type.
This has been a freelance NodeShell Rescue.