diff --git a/.travis.yml b/.travis.yml index 7a54f23..f3512f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ matrix: os: linux compiler: gcc sudo: false + - env: TASK="gcc6" # gcc-6 + os: linux + compiler: gcc-6 + sudo: false - env: TASK="arm-linux-gnueabihf-gcc" # arm build os: linux compiler: gcc @@ -57,6 +61,10 @@ addons: - mingw32-runtime - wine - xvfb + - gcc-6 + - g++-6 + sources: + - sourceline: 'ppa:ubuntu-toolchain-r/test' coverity_scan: project: name: "MycroftAI/mimic" diff --git a/run_testsuite.sh b/run_testsuite.sh index 311cefe..c9d157c 100755 --- a/run_testsuite.sh +++ b/run_testsuite.sh @@ -152,6 +152,18 @@ case "${WHAT_TO_RUN}" in # for ubuntu precise in travis, that does not provide pkg-config: pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu" pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata" + export CFLAGS="$CFLAGS --std=c99" + ./configure --enable-shared || exit 1 + make || exit 1 + make check || exit 1 + ;; + gcc6) + ./autogen.sh + # for ubuntu precise in travis, that does not provide pkg-config: + pkg-config --exists icui18n || export CFLAGS="$CFLAGS -I/usr/include/x86_64-linux-gnu" + pkg-config --exists icui18n || export LDFLAGS="$LDFLAGS -licui18n -licuuc -licudata" + export CC="/usr/bin/gcc-6" + export CXX="/usr/bin/g++-6" ./configure --enable-shared || exit 1 make || exit 1 make check || exit 1 diff --git a/src/audio/au_alsa.c b/src/audio/au_alsa.c index 9048e23..33770cf 100644 --- a/src/audio/au_alsa.c +++ b/src/audio/au_alsa.c @@ -43,7 +43,7 @@ #ifdef CST_AUDIO_ALSA -#define _BSD_SOURCE /* alsa alloca stuff and nanosleep */ +#define _POSIX_C_SOURCE 200112L #include #include @@ -56,6 +56,9 @@ #include "cst_wave.h" #include "cst_audio.h" +/* alloca.h is not C99 compliant nor POSIX compliant, but alsa needs it and does not include it */ +/* See similar patch: https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2008-July/058080.html */ +#include #include int audio_flush_alsa(cst_audiodev *ad); diff --git a/src/utils/cst_mmap_posix.c b/src/utils/cst_mmap_posix.c index 990072a..ac85f23 100644 --- a/src/utils/cst_mmap_posix.c +++ b/src/utils/cst_mmap_posix.c @@ -40,7 +40,7 @@ #if (MMAP_TYPE == MMAP_TYPE_POSIX) -# define _POSIX_C_SOURCE 200809L +# define _POSIX_C_SOURCE 200112L #include #include diff --git a/src/utils/cst_socket.c b/src/utils/cst_socket.c index f171c41..1aa3310 100644 --- a/src/utils/cst_socket.c +++ b/src/utils/cst_socket.c @@ -62,6 +62,7 @@ int cst_socket_close(int socket) return -1; } #else +#define _POSIX_C_SOURCE 200112L #include #include #ifndef _MSC_VER @@ -81,6 +82,11 @@ int cst_socket_close(int socket) #include "cst_socket.h" #include "cst_error.h" +/* OSX el capitan does not define INADDR_NONE in all cases */ +#ifndef INADDR_NONE +#define INADDR_NONE ((in_addr_t) -1) +#endif + int cst_socket_open(const char *host, int port) { /* Return an FD to a remote server */ @@ -105,7 +111,7 @@ int cst_socket_open(const char *host, int port) cst_errmsg("cst_socket: gethostbyname failed\n"); return -1; } - memmove(&serv_addr.sin_addr, serverhost->h_addr, + memmove(&serv_addr.sin_addr, serverhost->h_addr_list[0], serverhost->h_length); } serv_addr.sin_family = AF_INET; diff --git a/src/utils/cst_url.c b/src/utils/cst_url.c index 7437d28..d36c6a9 100644 --- a/src/utils/cst_url.c +++ b/src/utils/cst_url.c @@ -41,6 +41,9 @@ /* Only support http: if sockets are available */ /* */ /*************************************************************************/ + +#define _POSIX_C_SOURCE 200112L + #include #include "cst_file.h" #include "cst_string.h" diff --git a/unittests/cutest.h b/unittests/cutest.h index 64b5784..9031fa8 100644 --- a/unittests/cutest.h +++ b/unittests/cutest.h @@ -87,13 +87,12 @@ **********************/ /* The unit test files should not rely on anything below. */ - #include #include #include #include -#if defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__) +#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)) && !defined(__STRICT_ANSI__) #define CUTEST_UNIX__ 1 #include #include @@ -102,12 +101,16 @@ #include #endif -#if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__) +#if (defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)) && !defined(__STRICT_ANSI__) #define CUTEST_WIN__ 1 #include #include #endif +#if defined(__STRICT_ANSI__) + #define CUTEST_ANSI__ 1 +#endif + #ifdef __cplusplus #include #endif @@ -162,16 +165,16 @@ test_print_in_color__(int color, const char* fmt, ...) { const char* col_str; switch(color) { - case CUTEST_COLOR_GREEN__: col_str = "\e[0;32m"; break; - case CUTEST_COLOR_RED__: col_str = "\e[0;31m"; break; - case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\e[1;32m"; break; - case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\e[1;30m"; break; - case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\e[1m"; break; - default: col_str = "\e[0m"; break; + case CUTEST_COLOR_GREEN__: col_str = "\033[0;32m"; break; + case CUTEST_COLOR_RED__: col_str = "\033[0;31m"; break; + case CUTEST_COLOR_GREEN_INTENSIVE__: col_str = "\033[1;32m"; break; + case CUTEST_COLOR_RED_INTENSIVE__: col_str = "\033[1;30m"; break; + case CUTEST_COLOR_DEFAULT_INTENSIVE__: col_str = "\033[1m"; break; + default: col_str = "\033[0m"; break; } printf("%s", col_str); n = printf("%s", buffer); - printf("\e[0m"); + printf("\033[0m"); return n; } #elif defined CUTEST_WIN__ @@ -352,9 +355,10 @@ test_do_run__(const struct test__* test) return (test_current_failures__ == 0) ? 0 : -1; } +#if !defined(CUTEST_ANSI__) /* Called if anything goes bad in cutest, or if the unit test ends in other * way then by normal returning from its function (e.g. exception or some - * abnormal child process termination). */ + * abnormal child process termination). On CUTEST_ANSI__ this is not used so we don't define it*/ static void test_error__(const char* fmt, ...) { @@ -377,6 +381,7 @@ test_error__(const char* fmt, ...) printf("\n"); } } +#endif /* Trigger the unit test. If possible (and not suppressed) it starts a child * process who calls test_do_run__(), otherwise it calls test_do_run__() @@ -458,7 +463,7 @@ test_run__(const struct test__* test) failed = 1; } -#else +#else /* CUTEST_ANSI__ */ /* A platform where we don't know how to run child process. */ failed = (test_do_run__(test) != 0); @@ -650,4 +655,3 @@ main(int argc, char** argv) #endif /* #ifndef CUTEST_H__ */ -