I've seen something like that in a C-code and I'm wondering what it exactly does:
file.h
int f(int x);
file.c
inline int f(int x)
{
...
}
Basically the function is declared as inline in the C-file, but "normally" declared in the header-file.
Assuming f is never called in file.c, then the compiler should not be able to inline it into other translation units. Except for it LTO is used. However, does LTO (let's say gcc LTO) care about this inline? Probably it anyway inlines the function if it's small?
Or what's the effect of this in practice?
Assuming that foo.c includes foo.h, and assuming C99 or later, the declaration of f without the inline keyword makes the definition of foo an external definition.
This will allow foo to be called from other translation units, whether it's called in foo.c or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With