GNOME Bugzilla – Bug 640948
Error including gtkmm/dialog.h without first including gtkmm/box.h
Last modified: 2013-08-29 13:36:25 UTC
Hello, I have gtkmm-2.4 ver. 2.22.0, trying to compile a program of mine with -DGTK_DISABLE_DEPRECATED and -DGSEAL_ENABLE on Ubuntu Natty. If in a compilation unit I try to include dialog.h without first including box.h (I'm picking headers I need one by one, not using gtkmm.h), compilation fails with: ------------------------------------------------------------- In file included from /usr/include/gtkmm-2.4/gtkmm/dialog.h:30:0, from ../src/graphical_preferences_editor.hh:28, from ../src/graphical_preferences_editor.cc:24: /usr/include/gtkmm-2.4/gtkmm/box.h:105:1: error: expected class-name before ‘{’ token /usr/include/gtkmm-2.4/gtkmm/box.h:112:10: error: ‘_GtkBoxChild’ does not name a type /usr/include/gtkmm-2.4/gtkmm/box.h:114:16: error: ‘_GtkBoxChild’ does not name a type /usr/include/gtkmm-2.4/gtkmm/box.h: In member function ‘guint16 Gtk::Box_Helpers::Child::get_padding() const’: /usr/include/gtkmm-2.4/gtkmm/box.h:118:55: error: ‘gobj’ was not declared in this scope /usr/include/gtkmm-2.4/gtkmm/box.h: In member function ‘bool Gtk::Box_Helpers::Child::get_expand() const’: /usr/include/gtkmm-2.4/gtkmm/box.h:119:55: error: ‘gobj’ was not declared in this scope /usr/include/gtkmm-2.4/gtkmm/box.h: In member function ‘bool Gtk::Box_Helpers::Child::get_fill() const’: /usr/include/gtkmm-2.4/gtkmm/box.h:120:55: error: ‘gobj’ was not declared in this scope /usr/include/gtkmm-2.4/gtkmm/box.h: In member function ‘bool Gtk::Box_Helpers::Child::get_pack() const’: /usr/include/gtkmm-2.4/gtkmm/box.h:121:55: error: ‘gobj’ was not declared in this scope /usr/include/gtkmm-2.4/gtkmm/box.h: In member function ‘GtkBox* Gtk::Box_Helpers::Child::parent()’: /usr/include/gtkmm-2.4/gtkmm/box.h:130:52: error: ‘gobj’ was not declared in this scope ------------------------------------------------------------- Solution: add a #include <box.h> directive to dialog.h.
Do you have this problem with gtkmm 2.23/24? (for instance, from the branch in git)? box.h seems to be almost the first thing included from dialog.h so I don't understand how this could happen.
Please respond. I'd like to fix this if it's a real bug.
I'm still interested.
_GtkBoxChild is deprecated from 2.22, but it's still used in Gtk::Box. This potential problem is handled in gtkmm/box.h by temporarily undefining GTK_DISABLE_DEPRECATED before "#include <gtk/gtk.h>". But box.h is not the only gtkmm header file that includes gtk/gtk.h. If graphical_preferences_editor.cc or graphical_preferences_editor.hh in Matteo's program includes one of these other files before they include dialog.h or box.h, then gtk/gtk.h will be included with GTK_DISABLE_DEPRECATED defined, and _GtkBoxChild will not be defined when gtkmm/box.h is included. _GtkBoxChild has been removed in Gtk+ 3 and gtkmm 3. Shouldn't you have defined GTKMM_DISABLE_DEPRECATED instead of GTK_DISABLE_DEPRECATED? Or both of them? GTK_DISABLE_DEPRECATED will not disable any gtkmm API.
(In reply to comment #4) > If graphical_preferences_editor.cc > or graphical_preferences_editor.hh in Matteo's program includes one of these > other files before they include dialog.h or box.h, then gtk/gtk.h will be > included with GTK_DISABLE_DEPRECATED defined, and _GtkBoxChild will not be > defined when gtkmm/box.h is included. Matteo, do you include any GTK+ headers in your own code?
Or do you include gtkmm/table.h or gtkmm/treeiter.h before box.h or dialog.h? Or any file that includes gtkmm/treeiter.h? table.h and treeiter.h include gtk/gtk.h, and many files include treeiter.h.
_GtkBoxChild has been removed in gtkmm 3. In gtk+3 it's available only in gtkbox.c. This can't be a problem in gtkmm 3. Shall we keep such bugs as this one open? A bug only in gtkmm 2 that will almost certainly never be fixed in gtkmm 2.
Closing as obsolete.