-----------
static inline int foo() {
return 5;
}
inline int bar() {
return foo();
}
----
$ gcc -std=c99 -c inline-test.c
inline-test.c: In function 'bar':
inline-test.c:7: warning: 'foo' is static but used in inline function
'bar' which is not static
Is this code indeed a constraint violation?
(6.7.4 Function specifiers
Syntax
function-specifier:
inline
Constraints
Function specifiers shall be used only in the declaration of an
identifier for a function. 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.")
The actual inspiration for this question is Mac OS X's implementation
of the Posix ntohs() family of functions, which are implemented
(through various macro wrappers) as static inline functions; gcc thus
warns about any use of them in an external inline function.
Obviously, system headers aren't subject to the same conformance
constraints as user code. I'm trying, however, to determine whether
gcc should only suppress its warning for static inline functions
declared in a system header, or whether the warning is incorrect for
any calls to static inline functions.
--
Jonathan Lennox
jonathan at vidyo dot com
Since "foo" has internal linkage, that constraint is violated.
> I'm trying, however, to determine whether
> gcc should only suppress its warning for static inline functions
> declared in a system header, or whether the warning is incorrect for
> any calls to static inline functions.
I think the system header ought to be fixed.