This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: linux-2.2.1-ac3 and egcs-19990131


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]