glib/gtk and the standard

  • Thread starter Daniel C Bastos
  • Start date
D

Daniel C Bastos

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.
 
K

Kevin Easton

Daniel C Bastos said:
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.
 
M

Martin Ambuhl

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.
 
D

Dan Pop

In said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top