Having added the inline
to the function definition in the .c
file is just superfluous.
-
Your compilation unit of the
.c
file sees anextern
declaration (withoutinline
) and aninline
definition. Thus it emits the symbol for the function in the object file. -
All other compilation units only see an
extern
declaration, and so they can use the function without problems, if you link your final executable with the other.o
file.
In fact, you just have it the wrong way around. This feature is meant to be used that you have the inline
defintion in the .h
file, visible to everybody. This definition of the function only acts as a declaration of the symbol, just as extern
would, but doesn’t define it.
An extern
declaration in just one .c
file (compilation unit) then ensures such that the symbol is defined, there.
The terminology is a bit confusing, the inline
definition acting as declaration of the symbol, and the extern
declaration acting as definition of it