After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 728099 - add macro to check for gnuc version
add macro to check for gnuc version
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-04-13 00:08 UTC by Christian Hergert
Modified: 2018-05-24 16:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch adding G_GNUC_CHECK_VERSION() to gmacros.h (5.45 KB, patch)
2014-04-13 00:26 UTC, Christian Hergert
needs-work Details | Review
separate docs and macro addition (4.77 KB, patch)
2014-04-14 00:16 UTC, Christian Hergert
none Details | Review
add patch for docs (1.32 KB, patch)
2014-04-14 00:16 UTC, Christian Hergert
none Details | Review
macros: add G_GNUC_CHECK_VERSION() (1.91 KB, patch)
2014-04-14 00:19 UTC, Christian Hergert
committed Details | Review
macros: use G_GNUC_CHECK_VERSION() for compiler checks (4.41 KB, patch)
2014-04-14 00:19 UTC, Christian Hergert
reviewed Details | Review

Description Christian Hergert 2014-04-13 00:08:45 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)))))
Comment 1 Christian Hergert 2014-04-13 00:26:38 UTC
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.
Comment 2 Allison Karlitskaya (desrt) 2014-04-13 15:32:45 UTC
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?
Comment 3 Christian Hergert 2014-04-14 00:16:07 UTC
Created attachment 274217 [details] [review]
separate docs and macro addition
Comment 4 Christian Hergert 2014-04-14 00:16:27 UTC
Created attachment 274218 [details] [review]
add patch for docs
Comment 5 Christian Hergert 2014-04-14 00:17:06 UTC
oh im sorry, I read this wrong. I'll fix the patch separation.
Comment 6 Christian Hergert 2014-04-14 00:19:10 UTC
Created attachment 274219 [details] [review]
macros: add G_GNUC_CHECK_VERSION()
Comment 7 Christian Hergert 2014-04-14 00:19:34 UTC
Created attachment 274220 [details] [review]
macros: use G_GNUC_CHECK_VERSION() for compiler checks
Comment 8 Dan Winship 2014-05-01 15:47:46 UTC
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 9 Dan Winship 2014-05-01 15:48:26 UTC
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...
Comment 10 GNOME Infrastructure Team 2018-05-24 16:25:57 UTC
-- 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.