summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2019-01-07 23:23:52 -0600
committerEric Blake <eblake@redhat.com>2019-01-08 09:26:18 -0600
commit6933ebc497f5b432c0dc8c89450a2723c45371bd (patch)
treebcfeed51465b26a0275b565a9ccad125e244621f
parent30727583aed2e4655985916556418d8e44c5d2a9 (diff)
downloadlibvirt-6933ebc497f5b432c0dc8c89450a2723c45371bd.tar.gz
examples: Drop event-test.c dependency on gnulib <verify.h>
Pulling in gnulib just for the <verify.h> header is rather expensive, especially since that header does not require us to link against gnulib. It's better to make the event-test example be standalone by just open-coding a more limited form of a verify() macro that depends on modern gcc (we have enough CI coverage that even though the verify is now a no-op in older setups, we will still notice if we fail to add an event - as a quick test, I was still able to provoke a compile failure on Fedora 29 when deleting a line from domainEvents). Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
-rw-r--r--examples/object-events/event-test.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 8499e0b38e..6694d3dffc 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -6,8 +6,6 @@
#include <signal.h>
#include <inttypes.h>
-#include <verify.h>
-
#define VIR_ENUM_SENTINELS
#include <libvirt/libvirt.h>
@@ -17,6 +15,14 @@
#define STREQ(a, b) (strcmp(a, b) == 0)
#define NULLSTR(s) ((s) ? (s) : "<null>")
+#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
+ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
+ && !defined __cplusplus)
+# define verify(cond) _Static_assert(cond, "verify (" #cond ")")
+#else
+# define verify(cond)
+#endif
+
#ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
#endif