According to the comments on the question, defining static _inline
functions in header files is the way to go for this specific compiler, the quotation from the compiler doc is clear about that.
The problem you could later face is that it is a specific extension for a specific compiler, distinct from the standard inline
specifier. As said by Felix, the standard allows the implementation to choose how it implements inlining, and in particular, ignoring the specifier would still be conformant:
Making a function an inline function suggests that calls to the function be as
fast as possible. The extent to which such suggestions are effective is
implementation-defined.
That being said, the semantics seems to the the same (from draft 1256 for C99 or draft 1570 for C11):
6.7.4 Function specifiers
...
Any function with internal linkage can be an inline function. For a function with external
linkage, the following restrictions apply: If a function is declared with an inline
function specifier, then it shall also be defined in the same translation unit. If all of the
file scope declarations for a function in a translation unit include the inline function
specifier without extern, then the definition in that translation unit is an inline
definition. An inline definition does not provide an external definition for the function,
and does not forbid an external definition in another translation unit. An inline definition
provides an alternative to an external definition, which a translator may use to implement
any call to the function in the same translation unit. It is unspecified whether a call to the
function uses the inline definition or the external definition
So as common implementations do honour the inline
specifier, my opinion is that the risk in portability is limited
_inline
, but doesn't support pretty much anything from C99 (e.g. variables need to be declared first thing in a scope block). – Describe_inline
as opposed to the standardinline
, you should study the documentation of that compiler specific specifier very carefully. – Seagraves_inline
keyword, a C function can be defined to be inlined by the compiler. An inline function must be defined in the same source file before it is ’called’. When an inline function has to be called in several source files, each file must include the definition of the inline function. This is typically solved by defining the inline function in a header file." Perhaps you can add an answer with some info anyway? – Describeinline
. Sostatic _inline
may be okay. You'd have to examine the generated object files. – Seagraves#define foo(bar) do { int internal_##bar = bar; ... } while(0)
construct, i.e. perform the inlining within the preprocessor. Cause compilers are allowed to entirely ignoreinline
as they please. – Repose