glib/gtk and the standard

Discussion in 'C Programming' started by Daniel C Bastos, Jul 6, 2003.

  1. 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
    Daniel C Bastos, Jul 6, 2003
    #1
    1. Advertising

  2. Daniel C Bastos

    Kevin Easton Guest

    Daniel C Bastos <> 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.
    Kevin Easton, Jul 6, 2003
    #2
    1. Advertising

  3. Michael B Allen <> wrote (06 Jul 2003) in
    news:p / 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
    Martin Ambuhl, Jul 6, 2003
    #3
  4. Daniel C Bastos

    Dan Pop Guest

    In <Xns93B03639249B9mambuhlearthlinknet@207.217.77.22> Martin Ambuhl <> writes:

    >Michael B Allen <> wrote (06 Jul 2003) in
    >news:p / 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:
    Dan Pop, Jul 7, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    515
  2. Luke Kenneth Casson Leighton
    Replies:
    0
    Views:
    467
    Luke Kenneth Casson Leighton
    Dec 31, 2008
  3. Tor Lillqvist
    Replies:
    0
    Views:
    427
    Tor Lillqvist
    Dec 23, 2009
  4. Gergely Kontra
    Replies:
    2
    Views:
    248
    Joao Pedrosa
    Jun 18, 2004
  5. Y.G.

    [Fwd: Gtk and Glib::Timeout]

    Y.G., Jun 8, 2006, in forum: Perl Misc
    Replies:
    2
    Views:
    261
Loading...

Share This Page