Use escaped version of typeof

When compiling code that includes gobject.h using GCC with the ISO
standard, the `typeof` keyword is disabled, as it's a GCC extension.

The GCC documentation recommends:

> If you are writing a header file that must work when included in
> ISO C programs, write __typeof__ instead of typeof.

Which is precisely what we're going to do.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=790697
This commit is contained in:
Emmanuele Bassi 2017-12-08 12:56:55 +00:00
parent 3fae39a5d7
commit 9f3f089e60

View File

@ -510,8 +510,8 @@ void g_object_remove_weak_pointer (GObject *object,
#if defined(__GNUC__) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56
/* Make reference APIs type safe with macros */
#define g_object_ref(Obj) ((typeof(Obj)) (g_object_ref) (Obj))
#define g_object_ref_sink(Obj) ((typeof(Obj)) (g_object_ref_sink) (Obj))
#define g_object_ref(Obj) ((__typeof__(Obj)) (g_object_ref) (Obj))
#define g_object_ref_sink(Obj) ((__typeof__(Obj)) (g_object_ref_sink) (Obj))
#endif
/**