From: Bert Vermeulen Date: Mon, 25 Aug 2014 23:48:27 +0000 (+0200) Subject: Avoid warnings on all-zero static struct entries. X-Git-Tag: libsigrok-0.4.0~1120 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1685c27619b7c8c9041476d0db437081ac892d4f;p=libsigrok.git Avoid warnings on all-zero static struct entries. --- diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index fea409f0..6ce86883 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -143,6 +143,15 @@ libusb_handle_events_timeout(ctx, tv) #endif +/* Static definitions of structs ending with an all-zero entry are a + * problem when compiling with -Wmissing-field-initializers: GCC + * suppresses the warning only with { 0 }, clang wants { } */ +#ifdef __clang__ +#define ALL_ZERO { } +#else +#define ALL_ZERO { 0 } +#endif + struct sr_context { #ifdef HAVE_LIBUSB_1_0 libusb_context *libusb_ctx; diff --git a/src/output/ascii.c b/src/output/ascii.c index 9f69d007..b6baab1b 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -235,7 +235,7 @@ static int cleanup(struct sr_output *o) static struct sr_option options[] = { { "width", "Width", "Number of samples per line", NULL, NULL }, - { 0 } + ALL_ZERO }; static const struct sr_option *get_options(void) diff --git a/src/output/bits.c b/src/output/bits.c index 6b33f8d6..0a9ccc1a 100644 --- a/src/output/bits.c +++ b/src/output/bits.c @@ -221,7 +221,7 @@ static int cleanup(struct sr_output *o) static struct sr_option options[] = { { "width", "Width", "Number of samples per line", NULL, NULL }, - { 0 } + ALL_ZERO }; static const struct sr_option *get_options(void) diff --git a/src/output/hex.c b/src/output/hex.c index 6c0e15d5..67a349e5 100644 --- a/src/output/hex.c +++ b/src/output/hex.c @@ -235,7 +235,7 @@ static int cleanup(struct sr_output *o) static struct sr_option options[] = { { "width", "Width", "Number of samples per line", NULL, NULL }, - { 0 } + ALL_ZERO }; static const struct sr_option *get_options(void) diff --git a/src/output/wav.c b/src/output/wav.c index 9dc5a110..e01f3afd 100644 --- a/src/output/wav.c +++ b/src/output/wav.c @@ -336,7 +336,7 @@ static int cleanup(struct sr_output *o) static struct sr_option options[] = { { "scale", "Scale", "Scale values by factor", NULL, NULL }, - { 0 } + ALL_ZERO }; static const struct sr_option *get_options(void)