I am just confused by the inline keyword in C Programming language.
In my practice, an inline function has internal scope, so how does it differ with the
statickeyword?inline function has internal scope, but I saw some inline function plus the
statickeyword — what`s the use?
//temp.c
inline void exit_aio(){
puts("inline");
}
void test(){
exit_aio();//error,undefined reference to `exit_aio'
}
If I add the static keyword in the definition of function exit_aio(), then the program will work normally.
#includefiles.#include <stdio.h>and amain()function).inlinefunctions in C. Note thatinlineis a hint; the compiler can ignore the hint — and caninlinefunctions not explicitly markedinline. As a simple rule of thumb, make functionsstatic inlinein a header and include the header where you use the function.