The following code:
#include
inline int myfunc (int x) {
return x+3;
}
int main () {
printf(\"%d\", myfunc(2));
return 0;
}
You should declare 'myfunc' before define it. For example this code can be compiled with -std=gnu99 option:
#include
int myfunc(int);
inline int myfunc (int x) {
return x+3;
}
int main () {
printf("%d", myfunc(2));
return 0;
}
UPDATED
Actually, regarding to the C standard inline keyword is just a suggestion to the C compiler. But compiler can choose not to inline. So it can do its own way, therefore.
In your example you can use function declaration as I showed above - or you can add optimization flag '-O3' (tested on linux gcc) and above - in this case your source code will compiled without extra-declaration.
UPDATED
Here you can find deeper explanation: https://blogs.oracle.com/dew/entry/c99_inline_function