Commit 3272267b authored by Christian Hergert's avatar Christian Hergert Committed by Matthias Clasen
Browse files

macros: add G_GNUC_CHECK_VERSION() for compiler checks.

https://bugzilla.gnome.org/show_bug.cgi?id=728099
parent 21b1c390
......@@ -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
......
......@@ -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:
*
......
......@@ -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'.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment