As even the MSVC 2013 now supports the C99 mixing of declarations and code, we can now allow them in OVS code.
GCC (at least some versions of it) require the -std=c99 option to not issue warnings, and since we rely in GCC extensions when compiling with GCC, the option -std=gnu99 is now added to the CFLAGS by configure, if the compiler accepts it. Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- CodingStyle | 10 +++++----- acinclude.m4 | 2 +- configure.ac | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CodingStyle b/CodingStyle index bae8cd6..ef72c3e 100644 --- a/CodingStyle +++ b/CodingStyle @@ -533,14 +533,14 @@ C DIALECT * Designated initializers (e.g. "struct foo foo = {.a = 1};" and "int a[] = {[2] = 5};"). - Don't use other C99 features that are not widely implemented in -older compilers: - - * Don't mix declarations and code within a block. + * Mixing of declarations and code within a block. - * Don't use declarations in iteration statements (e.g. don't write + * Use of declarations in iteration statements (e.g. "for (int i = 0; i < 10; i++)"). + Don't use other C99 features that are not widely implemented in +older compilers: + * Don't put a trailing comma in an enum declaration (e.g. don't write "enum { x = 1, };"). diff --git a/acinclude.m4 b/acinclude.m4 index 5ed02d2..bd71a82 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -403,7 +403,7 @@ dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl - m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-], [_])])dnl + m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-=], [__])])dnl AC_CACHE_CHECK([whether $CC accepts $1], [ovs_cv_name], [ovs_save_CFLAGS="$CFLAGS" dnl Include -Werror in the compiler options, because without -Werror diff --git a/configure.ac b/configure.ac index 3379ff6..3387230 100644 --- a/configure.ac +++ b/configure.ac @@ -115,6 +115,7 @@ OVS_ENABLE_OPTION([-Wmissing-field-initializers]) OVS_ENABLE_OPTION([-Wthread-safety]) OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED]) OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER]) +OVS_CHECK_CC_OPTION([-std=gnu99], [CFLAGS="$CFLAGS -std=gnu99"]) OVS_ENABLE_WERROR OVS_ENABLE_SPARSE -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev