]> sigrok.org Git - libsigrokdecode.git/commitdiff
internal: introduce ALL_ZERO declaration, modelled after libsigrok
authorGerhard Sittig <redacted>
Sat, 25 Dec 2021 18:50:43 +0000 (19:50 +0100)
committerGerhard Sittig <redacted>
Sun, 26 Dec 2021 12:45:09 +0000 (13:45 +0100)
Declare ALL_ZERO in the common libsigrokdecode-internal.h header file.
The implementation and the comment on its motivation were taken from the
libsigrok implementation, slightly rephrased for improved readability.

libsigrokdecode-internal.h

index 329a10ab9462f7661c7e5a4f3a5390e4fd38fb19..453e14bf57a3bf45964ff8a59a92c78431dc76d1 100644 (file)
 #include <Python.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
 #include "libsigrokdecode.h"
 
+/*
+ * Static definition of tables ending with an all-zero sentinel entry
+ * may raise warnings when compiling with -Wmissing-field-initializers.
+ * GCC suppresses the warning only with { 0 }, clang wants { } instead.
+ */
+#ifdef __clang__
+#  define ALL_ZERO { }
+#else
+#  define ALL_ZERO { 0 }
+#endif
+
 enum {
        SRD_TERM_ALWAYS_FALSE,
        SRD_TERM_HIGH,