From: Doug Goldstein Date: Wed, 13 Nov 2013 16:46:03 +0000 (-0600) Subject: Macro for testing the version you are compiling with X-Git-Tag: v1.2.0-rc1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce83e91e6d54774f640201e114d0b2b0c134f60;p=thirdparty%2Flibvirt.git Macro for testing the version you are compiling with Added a macro similar to the GLib's GLIB_CHECK_VERSION so that one can simply do something like: #if LIBVIR_CHECK_VERSION(1,1,3) /* Call function here that appeared in 1.1.3 and newer */ virSomeNewFunction(); #endif --- diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index d656634bbb..146a59bb9d 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1466,6 +1466,22 @@ VIR_EXPORT_VAR virConnectAuthPtr virConnectAuthPtrDefault; #define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@ +/** + * LIBVIR_CHECK_VERSION: + * @major: major component of the version number + * @minor: minor component of the version number + * @micro: micro component of the version number + * + * Macro for developers to easily check what version of the library + * their code is compiling against. + * e.g. + * #if LIBVIR_CHECK_VERSION(1,1,3) + * // some code that only works in 1.1.3 and newer + * #endif + */ +#define LIBVIR_CHECK_VERSION(major, minor, micro) \ + ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER) + int virGetVersion (unsigned long *libVer, const char *type, unsigned long *typeVer);