avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Re: AVR-libc-dev Digest, Vol 22, Issue 22


From: Bill Somerville
Subject: [avr-libc-dev] Re: AVR-libc-dev Digest, Vol 22, Issue 22
Date: Thu, 30 Sep 2004 23:40:18 +0100

Geoffrey Wossum wrote:
> On Thursday 30 September 2004 5:02 pm, Bill Somerville wrote:
> 
> >
> > Declaring as static would make each non-inlined version local to the
> > translation unit that generates it. I think this is already implied by
> > the inline keyword.
> 
> Unless they changed the semantics in C99, inline does not imply static.
> 
> If you do
> 
> inline void somefunc(void) {}
> 
> in header file and include it in multiple compilation units, you will get
> multiple definition errors upon trying to link them together.  That's why you
> need to do "static inline" or "extern inline".

You are correct. I'm a C++ programmer and don't understand these new C99
think so well.

> 
> Personally, I prefer "extern inline", because then you know you'll never get a
> linkable version of the function generated in any object files.  However,
> I've read that "extern inline" is deprecated in GCC, and that "static inline"
> should be used for new code.  However, I think both glibc and the Linux
> kernel use "extern inline" all over the place, so it's probably not going
> away anytime soon.

I think that if extern inline is used then we must provide a non-inline
function in the library in case someone finds a good reason to take the
address of the inline fn's which is legal (just). That would cause a
whole bunch of complications. I think in this case static inline is the
best solution as the address can be taken and the compiler will do the
right thing without library fn's being required.

> 
> ---
> Geoffrey Wossum
> Long Range Systems - http://www.pager.net

Bill Somerville




reply via email to

[Prev in Thread] Current Thread [Next in Thread]