Re: [PATCH] guarantee that (GdkEventKey.state & GDK_RELEASE_MASK) is 0 in gdk_event_translate()



Darin Adler <darin eazel com> writes:

> on 12/3/00 8:50 AM, Owen Taylor at otaylor redhat com wrote:
> 
> > +/* Hack because GDK_RELEASE_MASK (a mistake in and of itself) was
> > + * accidentally given a value that overlaps with real bits in the
> > + * state field.
> > + */
> > +static inline guint
> > +translate_state (guint xstate)
> > +{
> > +  return xstate & ~GDK_RELEASE_MASK;
> > +}
> > +
> 
> Shouldn't this use G_INLINE_FUNC instead of inline?

No. To quote from the glib header file:

/* inlining hassle. for compilers that don't allow the `inline' keyword,
 * mostly because of strict ANSI C compliance or dumbness, we try to fall
 * back to either `__inline__' or `__inline'.
 * we define G_CAN_INLINE, if the compiler seems to be actually
 * *capable* to do function inlining, in which case inline function bodys
 * do make sense. we also define G_INLINE_FUNC to properly export the
 * function prototypes if no inlining can be performed.
 * we special case most of the stuff, so inline functions can have a normal
 * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1.
 */
#ifndef G_INLINE_FUNC
#  define G_CAN_INLINE 1
#endif
#ifdef G_HAVE_INLINE
#  if defined (__GNUC__) && defined (__STRICT_ANSI__)
#    undef inline
#    define inline __inline__
#  endif
#else /* !G_HAVE_INLINE */
#  undef inline
#  if defined (G_HAVE___INLINE__)
#    define inline __inline__
#  else /* !inline && !__inline__ */
#    if defined (G_HAVE___INLINE)
#      define inline __inline
#    else /* !inline && !__inline__ && !__inline */
#      define inline /* don't inline, then */
#      ifndef G_INLINE_FUNC
#	 undef G_CAN_INLINE
#      endif
#    endif
#  endif
#endif
#ifndef G_INLINE_FUNC
#  ifdef __GNUC__
#    ifdef __OPTIMIZE__
#      define G_INLINE_FUNC extern inline
#    else
#      undef G_CAN_INLINE
#      define G_INLINE_FUNC extern
#    endif
#  else /* !__GNUC__ */
#    ifdef G_CAN_INLINE
#      define G_INLINE_FUNC static inline
#    else
#      define G_INLINE_FUNC extern
#    endif
#  endif /* !__GNUC__ */
#endif /* !G_INLINE_FUNC */

Clear as day right? But the basic jist of that is that 'inline'
will always be defined and 'static inline' is the right thing
to use for an inline function within a file, while
G_INLINE_FUNC is more like GCC's 'extern inline'.

Regards,
                                        Owen





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