Is there a good reason for this?
From
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
(draft of C99+TC1+TC2+TC3 from 2007)
6.7.4/3:
"An inline definition of a function with external linkage shall not
contain a definition of a modifiable object with static storage
duration, and shall not contain a reference to an identifier with
internal linkage."
6.7.4/6:
"[...] 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."
If I understand this correctly, inline in C is more restrictive than
in C++ (w.r.t. static variables for example) and you have to (or
should) provide an "external definition" of an inline function with
external linkage in exactly one translation unit like this:
----------8<----------
// foo.h
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
inline int add(int a, int b) {return a+b;}
#endif
----------8<----------
// foo.c
#include "foo.h"
// This declaration makes the definition from the
// header an "external definition" in *this* TU.
extern inline int add(int,int);
----------8<----------
Did I get this right?
Cheers!
SG