mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
GLib: clean up the "inline" mess once and for all
It's been a long time since we've been unconditionally saying "static inline" in GLib headers without complaints so it's safe to assume that all compilers that we care about support this. One thing that is not yet totally supported is the unadorned use of the word "inline". Depending on the flags (-std=c89, for example), even GCC will complain about this. Detect missing C99 support and define "inline" to "__inline" in that case. Some research shows "__inline" appears to be the most widely-supported keyword here, but we may need to tweak this if we get some reports of breakage. Clean up all of the configure checks around this and define G_CAN_INLINE unconditionally. Unfortunately, we must assume that some people are still using G_IMPLEMENT_INLINES, we must continue to implement that (including undefining G_CAN_INLINE and redefining G_INLINE_FUNC) if requested. It is not our intent to break existing users of the old-style G_INLINE_FUNC approach and if that has happened, we may need to make some further adjustments. https://bugzilla.gnome.org/show_bug.cgi?id=757374
This commit is contained in:
105
configure.ac
105
configure.ac
@@ -623,78 +623,6 @@ AC_CACHE_CHECK([for growing stack pointer],glib_cv_stack_grows,[
|
||||
,)
|
||||
])
|
||||
|
||||
dnl AC_C_INLINE is useless to us since it bails out too early, we need to
|
||||
dnl truely know which ones of `inline', `__inline' and `__inline__' are
|
||||
dnl actually supported.
|
||||
AC_CACHE_CHECK([for __inline],glib_cv_has__inline,[
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
__inline int foo () { return 0; }
|
||||
int main () { return foo (); }
|
||||
]])],
|
||||
glib_cv_has__inline=yes
|
||||
,
|
||||
glib_cv_has__inline=no
|
||||
,)
|
||||
])
|
||||
case x$glib_cv_has__inline in
|
||||
xyes) AC_DEFINE(G_HAVE___INLINE,1,[Have __inline keyword])
|
||||
esac
|
||||
AC_CACHE_CHECK([for __inline__],glib_cv_has__inline__,[
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
__inline__ int foo () { return 0; }
|
||||
int main () { return foo (); }
|
||||
]])],
|
||||
glib_cv_has__inline__=yes
|
||||
,
|
||||
glib_cv_has__inline__=no
|
||||
,)
|
||||
])
|
||||
case x$glib_cv_has__inline__ in
|
||||
xyes) AC_DEFINE(G_HAVE___INLINE__,1,[Have __inline__ keyword])
|
||||
esac
|
||||
AC_CACHE_CHECK([for inline], glib_cv_hasinline,[
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#undef inline
|
||||
inline int foo () { return 0; }
|
||||
int main () { return foo (); }
|
||||
]])],
|
||||
glib_cv_hasinline=yes
|
||||
,
|
||||
glib_cv_hasinline=no
|
||||
,)
|
||||
])
|
||||
case x$glib_cv_hasinline in
|
||||
xyes) AC_DEFINE(G_HAVE_INLINE,1,[Have inline keyword])
|
||||
esac
|
||||
|
||||
# if we can use inline functions in headers
|
||||
AC_MSG_CHECKING(if inline functions in headers work)
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
#if defined (G_HAVE_INLINE) && defined (__GNUC__) && defined (__STRICT_ANSI__)
|
||||
# undef inline
|
||||
# define inline __inline__
|
||||
#elif !defined (G_HAVE_INLINE)
|
||||
# undef inline
|
||||
# if defined (G_HAVE___INLINE__)
|
||||
# define inline __inline__
|
||||
# elif defined (G_HAVE___INLINE)
|
||||
# define inline __inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int glib_test_func2 (int);
|
||||
|
||||
static inline int
|
||||
glib_test_func1 (void) {
|
||||
return glib_test_func2 (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (void) {
|
||||
int i = 1;
|
||||
}]])],[g_can_inline=yes],[g_can_inline=no])
|
||||
AC_MSG_RESULT($g_can_inline)
|
||||
|
||||
# check for flavours of varargs macros
|
||||
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
|
||||
AC_TRY_COMPILE([],[
|
||||
@@ -2906,26 +2834,6 @@ $glib_static_compilation
|
||||
|
||||
$glib_vacopy
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define G_HAVE_INLINE 1
|
||||
#else /* !__cplusplus */
|
||||
$glib_inline
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define G_CAN_INLINE 1
|
||||
_______EOF
|
||||
|
||||
if test x$g_can_inline = xyes ; then
|
||||
cat >>$outfile <<_______EOF
|
||||
#else /* !__cplusplus */
|
||||
#define G_CAN_INLINE 1
|
||||
_______EOF
|
||||
fi
|
||||
|
||||
cat >>$outfile <<_______EOF
|
||||
#endif
|
||||
|
||||
_______EOF
|
||||
|
||||
if test x$g_have_iso_c_varargs = xyes ; then
|
||||
@@ -3272,23 +3180,10 @@ if test x$glib_cv_va_val_copy = xno; then
|
||||
#define G_VA_COPY_AS_ARRAY 1"
|
||||
fi
|
||||
|
||||
if test x$glib_cv_hasinline = xyes; then
|
||||
glib_inline='#define G_HAVE_INLINE 1'
|
||||
fi
|
||||
if test x$glib_cv_has__inline = xyes; then
|
||||
glib_inline="\$glib_inline
|
||||
#define G_HAVE___INLINE 1"
|
||||
fi
|
||||
if test x$glib_cv_has__inline__ = xyes; then
|
||||
glib_inline="\$glib_inline
|
||||
#define G_HAVE___INLINE__ 1"
|
||||
fi
|
||||
|
||||
g_have_gnuc_varargs=$g_have_gnuc_varargs
|
||||
g_have_iso_c_varargs=$g_have_iso_c_varargs
|
||||
g_have_iso_cxx_varargs=$g_have_iso_cxx_varargs
|
||||
|
||||
g_can_inline=$g_can_inline
|
||||
g_have_gnuc_visibility=$g_have_gnuc_visibility
|
||||
g_have_sunstudio_visibility=$g_have_sunstudio_visibility
|
||||
|
||||
|
Reference in New Issue
Block a user