]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Drop gnu89/c89 support, switch to c99
authorSteffan Karger <steffan@karger.me>
Thu, 1 Sep 2016 20:14:30 +0000 (22:14 +0200)
committerDavid Sommerseth <davids@openvpn.net>
Fri, 16 Sep 2016 14:59:19 +0000 (16:59 +0200)
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 <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
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 <davids@openvpn.net>
configure.ac
src/openvpn/syshead.h

index 9189c94e526d00a6762adf7348cccea7b92ec20d..5c5cdf841ab6a8956c8f0e90ba22d0554a693800 100644 (file)
@@ -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"
index c8391ca3beadfef23b740469da0f1f45a7b386db..e969ccfa6355f800db40820856d38cad227173c1 100644 (file)
  * 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
 
 /*