Bug 41271 - Glib headers are not valid ISO C
Summary: Glib headers are not valid ISO C
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glib
Version: 7.1
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Owen Taylor
QA Contact: Aaron Brown
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-05-18 14:14 UTC by Alan Cox
Modified: 2005-10-31 22:00 UTC (History)
1 user (show)

(edit)
Clone Of:
(edit)
Last Closed: 2001-05-18 14:55:05 UTC


Attachments (Terms of Use)

Description Alan Cox 2001-05-18 14:14:56 UTC
gcc `gtk-config --cflags gtk` -g3 -c -pedantic -Wall url.c
In file included from /usr/include/gtk-1.2/gdk/gdktypes.h:33,
                 from /usr/include/gtk-1.2/gdk/gdk.h:31,
                 from /usr/include/gtk-1.2/gtk/gtk.h:31,
                 from parser.h:1,
                 from url.c:9:
/usr/include/glib-1.2/glib.h:1308:23: warning: ISO C does not permit named
variadic macros
/usr/include/glib-1.2/glib.h:1311:25: warning: ISO C does not permit named
variadic macros
/usr/include/glib-1.2/glib.h:1314:26: warning: ISO C does not permit named
variadic macros
/usr/include/glib-1.2/glib.h:1317:25: warning: ISO C does not permit named
variadic macros

Comment 1 Owen Taylor 2001-05-18 14:34:09 UTC
Looks like the #defines that were working in 7.0 to check:

#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L

for ISO C99 varargs macros were removed. Which I guess is fair,
since GCC doesn't implement ALL of C99. (Is this the right
explanation Jakub?) But it doesn't look
like there are any replacement macros that can be used properly:

#if (__GNUC__ == 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)

might work, but feels dirty, it looks like a configure time check
in GLib will probably have to be substituted.

Comment 2 Jakub Jelinek 2001-05-18 14:55:00 UTC
The issue is that unless you compile with -std=c99 or -std=gnu99,
__STDC_VERSION__ will not be above or equal to 199901L and glib.h will
use then the GNU variadic macros, but -pedantic properly warns that they
are not standard ISO C. Unfortunately, there is no __extension__ which could
disable this warning (since __extension__ is C lexer thing, not preprocessor
thing), so you have basically four options:
a) make sure glib.h is included via <glib-1.2/glib.h> (thus is found in
/usr/include and is considered a system header)
b) add something like:
#if (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
#pragma GCC system_header
#endif
above the variadic macros
c) do nothing, the warning is harmless
d) only use variadic macros for C99
Note that a) and b) will still issue warnings if -Wsystem-headers is passed,
but who cares.
b) looks like the best option to me.

Comment 3 Owen Taylor 2001-07-22 01:02:39 UTC
#pragma GCC system_header workaround added in glib-1.2.10-5


Note You need to log in before you can comment on or make changes to this bug.