• Kouhei Sutou's avatar
    Suppress -Wint-in-bool-context warning with G_DEFINE_INTERFACE and g++ · b8ac6e14
    Kouhei Sutou authored
    Note that it's not reported with gcc. It's only reported with g++.
    
    C++ code to reproduce this warning:
    
        #include <glib-object.h>
    
        G_BEGIN_DECLS
    
        #define GARROW_TYPE_FILE (garrow_file_get_type())
        G_DECLARE_INTERFACE(GArrowFile,
                            garrow_file,
                            GARROW,
                            FILE,
                            GObject)
    
        struct _GArrowFileInterface {
          GTypeInterface g_iface;
        };
    
        G_DEFINE_INTERFACE(GArrowFile,
                           garrow_file,
                           G_TYPE_OBJECT)
    
        static void
        garrow_file_default_init(GArrowFileInterface *iface)
        {
        }
    
        G_END_DECLS
    
    Build command line:
    
        % g++ -Wall -shared -o liba.so a.cpp $(pkg-config --cflags --libs gobject-2.0)
    
    Message:
    
        In file included from /tmp/local.glib/include/glib-2.0/gobject/gobject.h:24,
                         from /tmp/local.glib/include/glib-2.0/gobject/gbinding.h:29,
                         from /tmp/local.glib/include/glib-2.0/glib-object.h:23,
                         from a.cpp:1:
        a.cpp: In function 'GType garrow_file_get_type()':
        /tmp/local.glib/include/glib-2.0/gobject/gtype.h:219:50: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
         #define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
                                                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /tmp/local.glib/include/glib-2.0/gobject/gtype.h:2026:11: note: in definition of macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
               if (TYPE_PREREQ) \
                   ^~~~~~~~~~~
        /tmp/local.glib/include/glib-2.0/gobject/gtype.h:1758:47: note: in expansion of macro 'G_DEFINE_INTERFACE_WITH_CODE'
         #define G_DEFINE_INTERFACE(TN, t_n, T_P)      G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        a.cpp:16:1: note: in expansion of macro 'G_DEFINE_INTERFACE'
         G_DEFINE_INTERFACE(GArrowFile,
         ^~~~~~~~~~~~~~~~~~
        /tmp/local.glib/include/glib-2.0/gobject/gtype.h:178:25: note: in expansion of macro 'G_TYPE_MAKE_FUNDAMENTAL'
         #define G_TYPE_OBJECT   G_TYPE_MAKE_FUNDAMENTAL (20)
                                 ^~~~~~~~~~~~~~~~~~~~~~~
        a.cpp:18:20: note: in expansion of macro 'G_TYPE_OBJECT'
                            G_TYPE_OBJECT)
                            ^~~~~~~~~~~~~
    b8ac6e14
Name
Last commit
Last update
..
tests Loading commit data...
.gitignore Loading commit data...
Makefile.am Loading commit data...
gatomicarray.c Loading commit data...
gatomicarray.h Loading commit data...
gbinding.c Loading commit data...
gbinding.h Loading commit data...
gboxed.c Loading commit data...
gboxed.h Loading commit data...
gclosure.c Loading commit data...
gclosure.h Loading commit data...
genums.c Loading commit data...
genums.h Loading commit data...
glib-genmarshal.in Loading commit data...
glib-mkenums.in Loading commit data...
glib-types.h Loading commit data...
gmarshal.c Loading commit data...
gmarshal.h Loading commit data...
gobject-autocleanups.h Loading commit data...
gobject-query.c Loading commit data...
gobject.c Loading commit data...
gobject.h Loading commit data...
gobject.rc.in Loading commit data...
gobject.stp.in Loading commit data...
gobject_gdb.py Loading commit data...
gobject_probes.d Loading commit data...
gobject_trace.h Loading commit data...
gobjectnotifyqueue.c Loading commit data...
gparam.c Loading commit data...
gparam.h Loading commit data...
gparamspecs.c Loading commit data...
gparamspecs.h Loading commit data...
gsignal.c Loading commit data...
gsignal.h Loading commit data...
gsourceclosure.c Loading commit data...
gsourceclosure.h Loading commit data...
gtype-private.h Loading commit data...
gtype.c Loading commit data...
gtype.h Loading commit data...
gtypemodule.c Loading commit data...
gtypemodule.h Loading commit data...
gtypeplugin.c Loading commit data...
gtypeplugin.h Loading commit data...
gvalue.c Loading commit data...
gvalue.h Loading commit data...
gvaluearray.c Loading commit data...
gvaluearray.h Loading commit data...
gvaluecollector.h Loading commit data...
gvaluetransform.c Loading commit data...
gvaluetypes.c Loading commit data...
gvaluetypes.h Loading commit data...
libgobject-gdb.py.in Loading commit data...
meson.build Loading commit data...