From: Steffan Karger Date: Thu, 1 Sep 2016 20:14:30 +0000 (+0200) Subject: Drop gnu89/c89 support, switch to c99 X-Git-Tag: v2.4_alpha1~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=058f0efdec63aba911addee9ab205382c4762d06;p=thirdparty%2Fopenvpn.git Drop gnu89/c89 support, switch to c99 Previously, we would use the compiler's default C version, which defaults to gnu89 for GCC < 5, gnu11 for GCC > 5, and c11 for clang, but might even differ per distro. One of the reasons to accept the gnu89 default of GCC < 4.9, was that MSVC didn't support c99. But in MSVC 2015, MS finanally fixed that. Having to support c89 in the codebase occasionally forces us to write less readable code, for example by forcing all declaration to be at the starting of a block (which includes 'for loop initial declarations'). Let's be clear about what standard we obey, and stop punishing ourselves with c89/gnu89. Let's switch the master branch to c99. v2: don't try to detect pedantic mode based on __STRICT_ANSI__, since that will be defined when using -std=c99. v3: only set -std=c99 if there is no -std= already present in CFLAGS Signed-off-by: Steffan Karger Acked-by: David Sommerseth Message-Id: 1472760870-11769-1-git-send-email-steffan@karger.me URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg00194.html Signed-off-by: David Sommerseth --- diff --git a/configure.ac b/configure.ac index 9189c94e5..5c5cdf841 100644 --- a/configure.ac +++ b/configure.ac @@ -1125,10 +1125,16 @@ if test "${enable_pkcs11}" = "yes"; then ) fi +# Set -std=c99 unless user already specified a -std= +case "${CFLAGS}" in + *-std=*) ;; + *) CFLAGS="${CFLAGS} -std=c99" ;; +esac + if test "${enable_pedantic}" = "yes"; then enable_strict="yes" CFLAGS="${CFLAGS} -pedantic" - test "${WIN32}" != "yes" && CFLAGS="${CFLAGS} -std=c99" + AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode]) fi if test "${enable_strict}" = "yes"; then CFLAGS="${CFLAGS} -Wall -Wno-unused-parameter -Wno-unused-function" diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index c8391ca3b..e969ccfa6 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -384,16 +384,13 @@ * Pedantic mode is meant to accomplish lint-style program checking, * not to build a working executable. */ -#ifdef __STRICT_ANSI__ -# define PEDANTIC 1 +#ifdef PEDANTIC # undef HAVE_CPP_VARARG_MACRO_GCC # undef HAVE_CPP_VARARG_MACRO_ISO # undef EMPTY_ARRAY_SIZE # define EMPTY_ARRAY_SIZE 1 # undef inline # define inline -#else -# define PEDANTIC 0 #endif /*