Re: Inline C functions in Xcode 3
Re: Inline C functions in Xcode 3
- Subject: Re: Inline C functions in Xcode 3
- From: "Kyle Sluder" <email@hidden>
- Date: Sat, 3 Nov 2007 22:49:49 +0000
GCC has a lot of overlap between pre-standard keyword extensions and
underscore-adulterated extensions. inline is one of them:
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC99
--Kyle Sluder
On 11/3/07, Eric Albert <email@hidden> wrote:
> On Nov 3, 2007, at 3:21 PM, Steve Checkoway wrote:
>
> > On Nov 3, 2007, at 1:59 PM, Eric Albert wrote:
> >
> >> I'd strongly advise against using either FOUNDATION_STATIC_INLINE
> >> or CF_INLINE. Neither is supported for anything other than
> >> Foundation or CF's uses. They may work for you, but the
> >> Foundation and CF engineers may change them at any point.
> >
> > Speaking of inline, what is the difference (if any) between
> > __inline, __inline__, and __attribute__((always_inline))? Looking
> > at the definitions of CF_INLINE, I see:
> >
> > #if defined(__GNUC__) && (__GNUC__ == 4) && !defined(DEBUG)
> > #define CF_INLINE static __inline__ __attribute__
> > ((always_inline))
> > #elif defined(__GNUC__)
> > #define CF_INLINE static __inline__
> > #elif defined(__MWERKS__) || defined(__cplusplus)
> > #define CF_INLINE static inline
> > #elif defined(_MSC_VER)
> > #define CF_INLINE static __inline
> > #elif defined(__WIN32__)
> > #define CF_INLINE static __inline__
> > #endif
> >
> > Why this header using __inline__ __attribute__((always_inline)) for
> > gcc 4.x?
> >
> > Both C++98 and C99 include an inline keyword and they seem to be
> > about the same--as opposed to how gcc, at least, treats inline in
> > C89 vs. C99. Is there a reason to use __inline or __inline__ (both
> > of which do work with gcc) instead of inline?
>
> I'm not a compiler engineer and it's been a long time since I played
> one on TV, but here's what I think the differences are:
> • inline: Not a part of C89, but added in C99. Available as a GCC
> extension. A suggestion to the compiler that it may want to consider
> inlining the function.
> • __inline__: Explicitly a compiler extension due to the
> underscores. As with 'inline', also a suggestion.
> • __attribute__((always_inline)): A GCC extension which directs the
> compiler that it must inline the function unless it's technically
> impossible to do so.
>
> In general, you should use C99 (or any version of C++) and the inline
> keyword. __attribute__((always_inline)) should be avoided unless you
> know exactly what you're doing and you're certain the compiler isn't
> optimizing your functions declared inline well enough for you.
>
> Hope this helps,
> Eric
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden