On May 23, 2014, at 10:04 AM, Ben Pfaff <b...@nicira.com> wrote: > On Thu, May 22, 2014 at 05:37:38PM -0700, Jarno Rajahalme wrote: >> 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> > > Are you sure that this line in configure.ac isn't the root of the > problem? > > OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
I did not notice this, sorry. It turned out to be the problem, so there is no need to add the -std option. I left in the change in transliterating the ‘=‘ as well as ‘-‘ to ‘_’ so that if we ever need to add options with ‘=‘ in them, there should be no problems in doing so. > > I'm still really nervous about this one (I think it often uglifies code) > but let's give it a shot: > If it turns out to be too ugly we can always take this one back. >> - * Don't mix declarations and code within a block. >> + * Mixing of declarations and code within a block. > >> + Don't use other C99 features that are not widely implemented in >> +older compilers: >> + > > We have enough of these in the source that I think they're not a problem > in practice anymore, so let's delete this one too: > >> * Don't put a trailing comma in an enum declaration (e.g. don't >> write "enum { x = 1, };"). > Ok, I’ll change this too. How about this incremental: --- CodingStyle | 13 ++++++------- configure.ac | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CodingStyle b/CodingStyle index ef72c3e..0ba0366 100644 --- a/CodingStyle +++ b/CodingStyle @@ -515,7 +515,7 @@ global variables. C DIALECT - Some C99 features are OK because they are widely implemented: + Most C99 features are OK because they are widely implemented: * Flexible array members (e.g. struct { int foo[]; }). @@ -533,16 +533,15 @@ C DIALECT * Designated initializers (e.g. "struct foo foo = {.a = 1};" and "int a[] = {[2] = 5};"). - * Mixing of declarations and code within a block. + * Mixing of declarations and code within a block. Please use this + judiciously; keep declarations nicely grouped together in the + beginning of a block if possible. * 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, };"). + * Use of a trailing comma in an enum declaration (e.g. + "enum { x = 1, };"). As a matter of style, avoid // comments. diff --git a/configure.ac b/configure.ac index 3387230..4bf69e8 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,6 @@ OVS_ENABLE_OPTION([-Wall]) OVS_ENABLE_OPTION([-Wextra]) OVS_ENABLE_OPTION([-Wno-sign-compare]) OVS_ENABLE_OPTION([-Wpointer-arith]) -OVS_ENABLE_OPTION([-Wdeclaration-after-statement]) OVS_ENABLE_OPTION([-Wformat-security]) OVS_ENABLE_OPTION([-Wno-format-zero-length]) OVS_ENABLE_OPTION([-Wswitch-enum]) @@ -115,7 +114,6 @@ 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 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev