[PATCH] version.h: Add version check macro

Pier Luigi Fiorini pierluigi.fiorini at gmail.com
Sun Sep 22 22:26:03 PDT 2013


Make it easier to check for a Weston version.
---
 src/version.h.in | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/version.h.in b/src/version.h.in
index f573328..d45172c 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -26,6 +26,16 @@
 #define WESTON_VERSION_MAJOR @WESTON_VERSION_MAJOR@
 #define WESTON_VERSION_MINOR @WESTON_VERSION_MINOR@
 #define WESTON_VERSION_MICRO @WESTON_VERSION_MICRO@
-#define WESTON_VERSION "@WESTON_VERSION@"
+
+#define WESTON_VERSION ((WESTON_VERSION_MAJOR << 16) | (WESTON_VERSION_MINOR << 8) | (WESTON_VERSION_MICRO))
+#define WESTON_VERSION_STR "@WESTON_VERSION@"
+
+/*
+    Can be used like #if (WESTON_VERSION >= WESTON_VERSION_AT_LEAST(1, 2, 0))
+*/
+#define WESTON_VERSION_AT_LEAST(major, minor, micro) \
+        (WESTON_VERSION_MAJOR == (major) && \
+         WESTON_VERSION_MINOR == (minor) && \
+         WESTON_VERSION_MICRO >= (micro))
 
 #endif
-- 
1.8.3.1



More information about the wayland-devel mailing list