On Tue, Apr 05, 2011 at 10:21:18AM +0200, Mark Kettenis wrote: > > Date: Tue, 5 Apr 2011 09:44:21 +0200 > > From: Pascal Stumpf <pascal.stu...@cubes.de> > > > > On Mon, Apr 04, 2011 at 11:18:26AM -0700, Philip Guenther wrote: > > > On Mon, Apr 4, 2011 at 11:06 AM, Pascal Stumpf <pascal.stu...@cubes.de> > > > wrote: > > > > pcc currently only chokes on some inline functions that need external > > > > linkage. gcc isn't pesky about that, but pcc and clang are (rightfully, > > > > imo). > > > > > > It's completely legal and defined (by the standard and not just gcc!) > > > for a function to be inline in the file where it's defined and have > > > external linkage. That just means "inline if you can in this file, > > > but still provide a copy callable from other files". > > Not if it's never declared as extern, according to the standard. In that > > case it's an "inline definition", as they call it. > > No that's not what the standard says. The standard says that > something is an "inline definition" if *all* declarations of a > functions have "inline" on them. That clearly isn't the case here. > The standard also says that a function declaration with no > starage-class specifier on it has external linkage. So while there is > a (minor) ambuguity in the spec here, the logical conclusion would be > that C99 should behave as we expect and that clang (according to you, > but not according to jsg@) and pcc have a bug. Ok, I seem to have misread the standard there, sorry. Anyway, I've done some tests with all three compilers, and gotten three different behaviours:
"inline" declaration in header file *and* definition: Should be an inline definition, but gcc still creates external linkage, violating the standard. pcc and clang fail. So adding __inline to the declaration in pfvar.h shouldn't fix, but break the build with clang. Maybe that behaviour was changed after 2.8. non-inline declaration in header, but "inline" for the definition: gcc and clang work, pcc does not. Probably a bug in pcc, although ragge says it's conforming. "extern inline" on both the declaration and definition: pcc and clang work, gcc fails (why?). > > As long as we're stuck with gcc2 and gcc3 for some of our > architectures, working around those bugs in clang and pcc is not an > option.