By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,515 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,515 IT Pros & Developers. It's quick & easy.

glib/gtk and the standard

P: n/a
intro:
i have a simple c program that uses gtk (1.2) which in turn uses glib.

using the flag -Wall i get no warnings.
using -Wall -ansi no warnings.
using -Wall -ansi -pedantic I get these warnings

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 buncha_buttons.c:1:
/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

In glib.h, line 1308 I find:

#define g_error(format...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
format)

the other lines are similar #define statements.

question: what is named variadic macros? should the glib guys fix this?
should I upgrade and face the newest problems? should I just don't care
because who uses glib/gtk will never respect the standard? did I miss
some useful information on this matter? thanks for any input on this.

--
daniel
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Daniel C Bastos <da****@slashlog.org> wrote:
intro:
i have a simple c program that uses gtk (1.2) which in turn uses glib. [...] /usr/include/glib-1.2/glib.h:1308:23: warning: ISO C does not permit
named variadic macros [...] In glib.h, line 1308 I find:

#define g_error(format...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
format)

the other lines are similar #define statements.

question: what is named variadic macros?
It apparently refers to the way that the variadic portion of the macro's
arguments is named "format" here. The standard-compliant way of writing
that macro definition would be:

#define g_error(...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
__VA_ARGS__)
should the glib guys fix this?
Well, it doesn't seem to require much work to fix it, so I'd say "yes".
Especially if glib is intended to be compilable on non-gcc compilers.
should I upgrade and face the newest problems? should I just don't care
because who uses glib/gtk will never respect the standard? did I miss
some useful information on this matter? thanks for any input on this.


I think that's really up to you. It's trivial to fix those macros
yourself, if that's what you want to do.

- Kevin.

Nov 13 '05 #2

P: n/a
Michael B Allen <mb*****@ioplex.com> wrote (06 Jul 2003) in
news:pa*********************************@ioplex.co m / comp.lang.c:
Variadic macros are macros that accept a variable number of
arguments. They are defined in the C99 standard but not many
compilers impement them and I don't think gcc uses the defines C99
syntax anyway.


gcc handles at least all the example vararg macros from the C99
standard. Could you give an example of a C99 vararg macro that gcc
does not handle correctly? I don't doubt that there may be some.
Since I use the standard vararg mechanism for macros found in the
standard and do so with gcc, I would like to be sure that I don't
shot myself in the foot.

--
Martin Ambuhl
Returning soon to the
Fourth Largest City in America
Nov 13 '05 #3

P: n/a
In <Xn*********************************@207.217.77.22 > Martin Ambuhl <ma*****@earthlink.net> writes:
Michael B Allen <mb*****@ioplex.com> wrote (06 Jul 2003) in
news:pa*********************************@ioplex.c om / comp.lang.c:
Variadic macros are macros that accept a variable number of
arguments. They are defined in the C99 standard but not many
compilers impement them and I don't think gcc uses the defines C99
syntax anyway.


gcc handles at least all the example vararg macros from the C99
standard. Could you give an example of a C99 vararg macro that gcc
does not handle correctly? I don't doubt that there may be some.
Since I use the standard vararg mechanism for macros found in the
standard and do so with gcc, I would like to be sure that I don't
shot myself in the foot.


Since http://gcc.gnu.org/gcc-3.0/c99status.html claims that C99 macros
with a variable number of arguments are properly supported, it is
reasonable to assume that any 3.x version handles them properly.

OTOH, gcc also supports the GNU C syntax for vararg macros, which is
different from the C99 syntax.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.