GNOME Bugzilla – Bug 580302
no GTKMM_VERSION_*
Last modified: 2018-05-22 12:12:04 UTC
gtkmm/base.h defines macro to check the gtk version, but not the gtkmm version by way of GTKMM_VERSION_*
Is there a reason why gtkmm major/minor version should not match your gtkmm version?
I had to implement a GTKMM_* version check macros in my code. Consider this scenario: 1. I install a distro with gtk 2.10 and gtkmm 2.10. 2. I upgrade gtk to 2.12, without upgrading gtkmm. This is a perfectly valid situation, because installing newer gtk as some dependency doesn't automatically pull gtkmm. 3. Suddenly, my code doesn't compile, because I'm checking gtk version 2.12 with GTK_* macro, but using gtkmm (2.12!) API, which is still at 2.10.
(In reply to comment #1) > Is there a reason why gtkmm major/minor version should not match your gtkmm > version? > For the same reason that they are different packages.
perhaps johannes means gtkmm_major_version, etc ? Those are normal variables and are not usable from the preprocessor, so you can't do something like the following pseudo-code: #ifdef GTKMM_VERSION > x.y Gtk::symbol_that_does_not_exist_in_older_versions() #endif
Yes, I recently had to use the separate defines (such as GTKMM MICRO_VERSION), which was not so nice. A patch would be welcome.
I can make one or more patches, but I don't know exactly what people want. There are a lot of version checking macros around. I suspect that the most useful macro would be one similar to /** * GTK_CHECK_VERSION: * @major: major version (e.g. 1 for version 1.2.5) * @minor: minor version (e.g. 2 for version 1.2.5) * @micro: micro version (e.g. 5 for version 1.2.5) * * Returns %TRUE if the version of the GTK+ header files * is the same as or newer than the passed-in version. */ #define GTK_CHECK_VERSION(major,minor,micro) \ (GTK_MAJOR_VERSION > (major) || \ (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION > (minor)) || \ (GTK_MAJOR_VERSION == (major) && GTK_MINOR_VERSION == (minor) && \ GTK_MICRO_VERSION >= (micro))) in http://git.gnome.org/browse/gtk+/tree/gtk/gtkversion.h.in Perhaps a more general macro? #define GLIBMM_CHECK_LIBRARY_VERSION(library,major,minor,micro) \ (library ## _MAJOR_VERSION > (major) || \ (library ## _MAJOR_VERSION == (major) && \ library ## _MINOR_VERSION > (minor)) || \ (library ## _MAJOR_VERSION == (major) && \ library ## _MINOR_VERSION == (minor) && \ library ## _MICRO_VERSION >= (micro))) Examples of macro calls: #if GLIBMM_CHECK_LIBRARY_VERSION(GLIBMM, 2, 32, 0) #if GLIBMM_CHECK_LIBRARY_VERSION(GTKMM, 3, 4, 2) It would of course be possible to define macros such as #define GLIBMM_CHECK_VERSION(major,minor,micro) \ GLIBMM_CHECK_LIBRARY_VERSION(GLIBMM,major,minor,micro) #define GIOMM_CHECK_VERSION(major,minor,micro) \ GLIBMM_CHECK_LIBRARY_VERSION(GIOMM,major,minor,micro) #define GDKMM_CHECK_VERSION(major,minor,micro) \ GLIBMM_CHECK_LIBRARY_VERSION(GDKMM,major,minor,micro) #define GTKMM_CHECK_VERSION(major,minor,micro) \ GLIBMM_CHECK_LIBRARY_VERSION(GTKMM,major,minor,micro) Are equivalents to all the macros in gtkmm/base.h useful? GTKMM_VERSION_GT(major,minor) GTKMM_VERSION_GE(major,minor) GTKMM_VERSION_EQ(major,minor) GTKMM_VERSION_NE(major,minor) GTKMM_VERSION_LE(major,minor) GTKMM_VERSION_LT(major,minor) GTKMM_VERSION_GT_MICRO(major,minor,micro)
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtkmm/issues/5.