[PATCH] Macro for testing the version you are compiling with

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Added a macro similar to the Linux kernel's KERNEL_VERSION so that you
can simply do something like:

 #if LIBVIR_VERSION(1,1,3) <= LIBVIR_VERSION_NUMBER
   /* Call function here that appeared in 1.1.3 and newer */
   virSomeNewFunction();
 #endif
---
 include/libvirt/libvirt.h.in | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 80b2d78..41a8c69 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1466,6 +1466,16 @@ VIR_EXPORT_VAR virConnectAuthPtr virConnectAuthPtrDefault;
 
 #define LIBVIR_VERSION_NUMBER @LIBVIRT_VERSION_NUMBER@
 
+/**
+ * LIBVIR_VERSION:
+ *
+ * Macro for developers to easily check what version of the library
+ * their code is compiling against. Similar in behavior to KERNEL_VERSION
+ * e.g.
+ * #if LIBVIR_VERSION(1,1,3) < LIBVIR_VERSION_NUMBER
+ */
+#define LIBVIR_VERSION(a,b,c) (((a) * 1000000) + ((b) * 1000) + (c))
+
 int                     virGetVersion           (unsigned long *libVer,
                                                  const char *type,
                                                  unsigned long *typeVer);
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]