After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 522292 - Gives warnings in glib/gutils.h with GCC in C99 mode
Gives warnings in glib/gutils.h with GCC in C99 mode
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.16.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 521647 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-03-13 19:33 UTC by Sebastian Dröge (slomo)
Modified: 2008-03-31 09:02 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
fix warnings in glib/gutils.h with GCC in C99 mode (474 bytes, patch)
2008-03-17 21:08 UTC, Christian Kirbach
committed Details | Review

Description Sebastian Dröge (slomo) 2008-03-13 19:33:29 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.
Comment 1 Sebastian Dröge (slomo) 2008-03-13 19:34:09 UTC
It should also be said, that with gcc 4.3 this warnings disappear, the patch is still correct though.
Comment 2 Murray Cumming 2008-03-17 14:24:44 UTC
*** Bug 521647 has been marked as a duplicate of this bug. ***
Comment 3 Christian Kirbach 2008-03-17 21:04:34 UTC
This has bitten me for gnome-vfs from svn.
Patch works for me
Comment 4 Christian Kirbach 2008-03-17 21:06:01 UTC
Applies to 2.16
Comment 5 Christian Kirbach 2008-03-17 21:08:38 UTC
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.
Comment 6 Sebastian Dröge (slomo) 2008-03-18 20:02:46 UTC
Ok, committed this to trunk and 2.16 branch.
Comment 7 Tim Janik 2008-03-31 08:27:15 UTC
(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...
Comment 8 Sebastian Dröge (slomo) 2008-03-31 08:52:14 UTC
I asked Matthias Clasen on IRC if it's ok to commit this patch.
Comment 9 Tim Janik 2008-03-31 09:02:30 UTC
(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.