GNOME Bugzilla – Bug 522292
Gives warnings in glib/gutils.h with GCC in C99 mode
Last modified: 2008-03-31 09:02:30 UTC
Hi, quoting the Debian bug: http://bugs.debian.org/470796 When a C program that includes <glib/gutils.h> is built with gcc -std=gnu99 or with gcc -std=c99, warnings are provoked by the GLib headers. When gcc is invoked with -std=gnu89 (the default) or -std=c89, there are no warnings. Many projects use -Werror for compilation (at least for development versions), and AC_PROG_CC_STDC selects -std=gnu99 by default, so this prevents compilation of (for instance) development versions of Telepathy components. A shell session reproducing the problem is shown below: smcv@carbon% cp /usr/include/glib-2.0/glib/gutils.h mygutils.h smcv@carbon% cat > tmp.c #include "mygutils.h" int main (void) { return 0; } smcv@carbon% gcc -std=gnu89 `pkg-config --libs --cflags glib-2.0` tmp.c smcv@carbon% gcc -std=gnu99 `pkg-config --libs --cflags glib-2.0` tmp.c In file included from tmp.c:1: mygutils.h:320: warning: C99 inline functions are not supported; using GNU89 mygutils.h:320: warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute mygutils.h:334: warning: C99 inline functions are not supported; using GNU89 mygutils.h:347: warning: C99 inline functions are not supported; using GNU89 mygutils.h:366: warning: C99 inline functions are not supported; using GNU89 mygutils.h:374: warning: C99 inline functions are not supported; using GNU89 mygutils.h:391: warning: C99 inline functions are not supported; using GNU89 mygutils.h:400: warning: C99 inline functions are not supported; using GNU89 I suggest patching gutils.h like this: --- gutils.h.orig 2008-03-13 18:14:53.000000000 +0000 +++ mygutils.h 2008-03-13 18:15:19.000000000 +0000 @@ -97,7 +97,7 @@ # define G_INLINE_FUNC # undef G_CAN_INLINE #elif defined (__GNUC__) -# ifdef __GNUC_STDC_INLINE__ +# if defined (__GNUC_STDC_INLINE__) || defined (__GNUC_GNU_INLINE__) # define G_INLINE_FUNC extern inline __attribute__ ((__gnu_inline__)) # else # define G_INLINE_FUNC extern inline info gcc says: [the gnu_inline attribute] is available if either of the preprocessor macros `__GNUC_GNU_INLINE__' or `__GNUC_STDC_INLINE__' are defined so I believe this is a correct patch. info gcc also says: In versions prior to 4.3, the only effect of explicitly including it is to disable warnings about using inline functions in C99 mode.
It should also be said, that with gcc 4.3 this warnings disappear, the patch is still correct though.
*** Bug 521647 has been marked as a duplicate of this bug. ***
This has bitten me for gnome-vfs from svn. Patch works for me
Applies to 2.16
Created attachment 107483 [details] [review] fix warnings in glib/gutils.h with GCC in C99 mode Patch from Sebastian Dröge Attaching it as a patch file When a C program that includes <glib/gutils.h> is built with gcc -std=gnu99 or with gcc -std=c99 (like some projects), warnings are provoked by the GLib headers. When gcc is invoked with -std=gnu89 (the default) or -std=c89, there are no warnings.
Ok, committed this to trunk and 2.16 branch.
(In reply to comment #6) > Ok, committed this to trunk and 2.16 branch. please don't commit patches to glib without proper review, fixing/reverting now...
I asked Matthias Clasen on IRC if it's ok to commit this patch.
(In reply to comment #8) > I asked Matthias Clasen on IRC if it's ok to commit this patch. thanks for the note, taking this up with Matthias now.