glib2 G_GNUC_UNUSED

Elan Ruusamäe glen at delfi.ee
Wed Nov 29 00:10:14 CET 2006


anyone? qboosh?


anyway i've looked how linux uses __used__:

/usr/src/linux/include/linux/compiler.h:

#if __GNUC__ > 4
#error no compiler-gcc.h file for this gcc version
#elif __GNUC__ == 4
# include <linux/compiler-gcc4.h>
#elif __GNUC__ == 3
# include <linux/compiler-gcc3.h>
#else
# error Sorry, your compiler is too old/not recognized.
#endif

/usr/src/linux/include/linux/compiler-gcc3.h:
#if __GNUC_MINOR__ >= 3
# define __attribute_used__ __attribute__((__used__))
#else
# define __attribute_used__ __attribute__((__unused__))
#endif

and /usr/src/linux/include/linux/compiler.h continues:
#ifndef __attribute_used__
# define __attribute_used__ /* unimplemented */
#endif

maybe this will help.

On Friday 03 November 2006 02:21, Elan Ruusamäe wrote:
> is glib2 defining the macro incompatible for gcc in Ac, or there's some
> other cause?
>
> $ g++ -c t.c `pkg-config --cflags glib-2.0` `pkg-config --cflags gtk+-2.0`
> t.c:5: error: syntax error before `__attribute__'
>
> $ cat t.c
> #include <gtk/gtk.h>
> #include <glib.h>
>
> static void open_url_cb( GtkWidget *pButton G_GNUC_UNUSED, gpointer data )
> {
> }
>
> $ g++ -E t.c `pkg-config --cflags glib-2.0` `pkg-config --cflags
> gtk+-2.0`>t.C $ grep open_url_cb t.C
> static void open_url_cb( GtkWidget *pButton __attribute__((__unused__)),
> gpointer data )
>
> $ q gcc glib2 gtk+2
> gcc-5:3.3.6-4
> glib2-1:2.10.3-1
> gtk+2-2:2.8.20-1
> $
>
> http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Macros.html#
>G-GNUC-UNUSED:CAPS

-- 
glen


More information about the pld-devel-en mailing list