From: Gerhard Sittig Date: Sat, 25 Dec 2021 18:50:43 +0000 (+0100) Subject: internal: introduce ALL_ZERO declaration, modelled after libsigrok X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3db0d9750d6947080ae1cfe4ba1108a1687cf24f;p=libsigrokdecode.git internal: introduce ALL_ZERO declaration, modelled after libsigrok 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. --- diff --git a/libsigrokdecode-internal.h b/libsigrokdecode-internal.h index 329a10a..453e14b 100644 --- a/libsigrokdecode-internal.h +++ b/libsigrokdecode-internal.h @@ -27,6 +27,17 @@ #include /* 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,