macros: add G_GNUC_CHECK_VERSION() for compiler checks.

https://bugzilla.gnome.org/show_bug.cgi?id=728099
This commit is contained in:
Christian Hergert 2014-04-13 17:17:59 -07:00 committed by Matthias Clasen
parent 21b1c390a3
commit 3272267b99
3 changed files with 22 additions and 0 deletions

View File

@ -407,6 +407,7 @@ G_STATIC_ASSERT
G_STATIC_ASSERT_EXPR
<SUBSECTION>
G_GNUC_CHECK_VERSION
G_GNUC_EXTENSION
G_GNUC_CONST
G_GNUC_PURE

View File

@ -1995,6 +1995,21 @@
* with the `-pedantic` option.
*/
/**
* G_GNUC_CHECK_VERSION:
*
* Expands to a a check for a compiler with __GNUC__ defined and a version
* greater than or equal to the major and minor numbers provided. For example,
* the following would only match on compilers such as GCC 4.8 or newer.
*
* |[<!-- language="C" -->
* #if G_GNUC_CHECK_VERSION(4, 8)
* #endif
* ]|
*
* Since: 2.42
*/
/**
* G_GNUC_CONST:
*

View File

@ -37,6 +37,12 @@
*/
#include <stddef.h>
#define G_GNUC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && \
((__GNUC__ > (major)) || \
((__GNUC__ == (major)) && \
(__GNUC_MINOR__ >= (minor)))))
/* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
* where this is valid. This allows for warningless compilation of
* "long long" types even in the presence of '-ansi -pedantic'.