From: Uwe Hermann Date: Tue, 19 Nov 2013 10:48:06 +0000 (+0100) Subject: Fix a bunch of compiler warnings. X-Git-Tag: sigrok-cli-0.5.0~59 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=20fb52e08416238c60392b410f69856cc7d98650;p=sigrok-cli.git Fix a bunch of compiler warnings. We need to ensure that libsigrokdecode.h is always the first #include, otherwise some versions of Python will cause all kinds of compiler warnings like these: CC device.o In file included from /usr/include/python3.2mu/Python.h:8:0, from [...]/include/libsigrokdecode/libsigrokdecode.h:25, from sigrok-cli.h:26, from device.c:23: /usr/include/python3.2mu/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default] #define _POSIX_C_SOURCE 200112L ^ In file included from /usr/include/limits.h:26:0, from /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/limits.h:168, from /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/syslimits.h:7, from /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/limits.h:34, from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:11, from /usr/include/glib-2.0/glib/gtypes.h:34, from /usr/include/glib-2.0/glib/galloca.h:34, from /usr/include/glib-2.0/glib.h:32, from device.c:21: /usr/include/features.h:231:0: note: this is the location of the previous definition # define _POSIX_C_SOURCE 200809L ^ Since sigrok-cli.h already #includes libsigrok.h and libsigrokdecode.h, just ensure that the latter is always the first #include by _only_ including it in sigrok-cli.h and nowhere else. --- diff --git a/anykey.c b/anykey.c index 24970c2..f11b0d7 100644 --- a/anykey.c +++ b/anykey.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include #ifdef _WIN32 #include @@ -26,8 +27,6 @@ #include #include #include -#include -#include "sigrok-cli.h" #ifdef _WIN32 static HANDLE stdin_handle; diff --git a/decode.c b/decode.c index 28b156b..bc36a84 100644 --- a/decode.c +++ b/decode.c @@ -17,13 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#ifdef HAVE_SRD -#include /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#endif -#include "sigrok-cli.h" #ifdef HAVE_SRD static GHashTable *pd_ann_visible = NULL; diff --git a/device.c b/device.c index 2dc8308..28184ce 100644 --- a/device.c +++ b/device.c @@ -17,10 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#include "sigrok-cli.h" extern struct sr_context *sr_ctx; extern gchar *opt_drv; diff --git a/input.c b/input.c index 7ef694d..5650b9f 100644 --- a/input.c +++ b/input.c @@ -17,10 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#include "sigrok-cli.h" extern gchar *opt_input_file; extern gchar *opt_input_format; diff --git a/main.c b/main.c index abacea9..9ab3f77 100644 --- a/main.c +++ b/main.c @@ -17,13 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#ifdef HAVE_SRD -#include /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#endif -#include "sigrok-cli.h" struct sr_context *sr_ctx = NULL; #ifdef HAVE_SRD diff --git a/parsers.c b/parsers.c index 059d339..f587f8d 100644 --- a/parsers.c +++ b/parsers.c @@ -17,13 +17,12 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include #include #include #include #include -#include -#include "sigrok-cli.h" static struct sr_probe *find_probe(GSList *probelist, const char *probename) { diff --git a/session.c b/session.c index 12033dc..130eed5 100644 --- a/session.c +++ b/session.c @@ -17,14 +17,10 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include #include -#include -#ifdef HAVE_SRD -#include /* First, so we avoid a _POSIX_C_SOURCE warning. */ -#endif -#include "sigrok-cli.h" static struct sr_output_format *output_format = NULL; static int default_output_format = FALSE; diff --git a/show.c b/show.c index 07341c9..db643d1 100644 --- a/show.c +++ b/show.c @@ -17,13 +17,9 @@ * along with this program. If not, see . */ +#include "sigrok-cli.h" #include "config.h" #include -#include -#ifdef HAVE_SRD -#include -#endif -#include "sigrok-cli.h" extern gint opt_loglevel; extern gchar *opt_pds; diff --git a/sigrok-cli.h b/sigrok-cli.h index 74e4fda..27ae876 100644 --- a/sigrok-cli.h +++ b/sigrok-cli.h @@ -21,10 +21,11 @@ #define SIGROK_CLI_SIGROK_CLI_H #include "config.h" -#include #ifdef HAVE_SRD +/* First, so we avoid a _POSIX_C_SOURCE warning. */ #include #endif +#include #define DEFAULT_OUTPUT_FORMAT "bits:width=64"