I don't understand why this is not possible :
inline void f(void) {}
int main(void)
{
f();
}
Answer from extern inline:
C99 (or GNU99):
"inline": like GNU "extern inline"; no externally visible function is emitted, but one might be called and so must exist
Question 1:
What I understood is that f() is not externally visible , for me externally visible means that I can't call f() from another file , but here I'm calling it directly in main.What's the problem?
Solution
to put the definition in the .h file.
inline void f(void) {}
and the declaration in only one .c file
extern inline void f(void);
Question 2 :
But I could also do :
this declaration goes in the header file
extern inline void f(void);
and this definition goes only in one .c file
extern void f(void) {}
and now I can use the function how I want , only condition is not to write
extern void f(void) {}
in any other .c file.
What are the risk if I don't use the "normal" solution , and do like I just wrote ?
compiled with
gcc -std=c11