macros: make G_GNUC_CHECK_VERSION() portable

This removes the use of defined() in a macro expansion, which may not be
portable to some pre-processors. Instead, we hoist the defined check
outside the macro expansion.

https://bugzilla.gnome.org/show_bug.cgi?id=790877
This commit is contained in:
Christian Hergert 2017-11-26 16:00:46 -08:00
parent f5dba7d43c
commit d44afbadda

View File

@ -37,11 +37,14 @@
*/
#include <stddef.h>
#ifdef __GNUC__
#define G_GNUC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && \
((__GNUC__ > (major)) || \
((__GNUC__ == (major)) && \
(__GNUC_MINOR__ >= (minor)))))
((__GNUC__ > (major)) || \
((__GNUC__ == (major)) && \
(__GNUC_MINOR__ >= (minor))))
#else
#define G_GNUC_CHECK_VERSION(major, minor) 0
#endif
/* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
* where this is valid. This allows for warningless compilation of