GNOME Bugzilla – Bug 728099
add macro to check for gnuc version
Last modified: 2018-05-24 16:25:57 UTC
We have checks for various __GNUC__ versions all over the code-base. Also, from a lot of libraries that are consuming GLib. It would be nice to have a helper for this in glib-macros.h. Something like: #define G_GNUC_CHECK_VERSION(major, minor) \ (defined(__GNUC__) && \ ((__GNUC__ > (major)) || \ ((__GNUC__ == (major)) && \ (__GNUC_MINOR__ >= (minor)))))
Created attachment 274191 [details] [review] Patch adding G_GNUC_CHECK_VERSION() to gmacros.h macros: add G_GNUC_CHECK_VERSION(major,minor) macro This makes compiler version checks a bit simpler and clearer to read. One might argue we should include a check for patch version, but I don't think it is the common case, so might be better to check that separately. Includes docs and updates gmacros.h to use the check.
Review of attachment 274191 [details] [review]: You're missing the addition to -sections.txt Can you add the macro (with docs) in one commit and introduce all of the uses from another?
Created attachment 274217 [details] [review] separate docs and macro addition
Created attachment 274218 [details] [review] add patch for docs
oh im sorry, I read this wrong. I'll fix the patch separation.
Created attachment 274219 [details] [review] macros: add G_GNUC_CHECK_VERSION()
Created attachment 274220 [details] [review] macros: use G_GNUC_CHECK_VERSION() for compiler checks
Comment on attachment 274219 [details] [review] macros: add G_GNUC_CHECK_VERSION() >+#define G_GNUC_CHECK_VERSION(major, minor) \ >+ (defined(__GNUC__) && \ >+ ((__GNUC__ > (major)) || \ You don't need to check defined(__GNUC__). If it's not defined, it will expand to 0 in mathematical expressions.
Comment on attachment 274220 [details] [review] macros: use G_GNUC_CHECK_VERSION() for compiler checks good, but there are GNUC version checks in a bunch of other files too...
-- 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/glib/issues/857.