Bug 41271

Summary: Glib headers are not valid ISO C
Product: [Retired] Red Hat Linux Reporter: Alan Cox <alan>
Component: glibAssignee: Owen Taylor <otaylor>
Status: CLOSED RAWHIDE QA Contact: Aaron Brown <abrown>
Severity: low Docs Contact:
Priority: low    
Version: 7.1CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-05-18 10:55:05 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Alan Cox 2001-05-18 10:14:56 EDT
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 10:34:09 EDT
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 10:55:00 EDT
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
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-21 21:02:39 EDT
#pragma GCC system_header workaround added in glib-1.2.10-5