linux-2.2.1-ac3 and egcs-19990131
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun Feb 28 23:30:00 GMT 1999
> Gee, and I thought only C++ provided extern inline:
It seems that ISO C 99 has extern inline functions. 6.7.4/2 says
>> 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.
And paragraph 6 says
>> 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.
I don't understand this entirely. It seems that there must be exactly
one definition of such a function in a single translation unit, which
is then used by other translation units. To me, this allows the
following usage
/* foo.h */
inline void foo(){}
/* foo.c */
extern void foo(); /* Compiler emits out-of-line code in foo.o */
/* bar.c */
void bar(){
foo(); /* Inline call */
}
void* bar1(){
extern void foo();
return (void*)&foo;
}
Any comments?
Martin
More information about the Gcc-bugs
mailing list