#754268 commandline-specified CFLAGS override -std= parameter from AC_PROG_CC_C99

#754268#5
Date:
2014-07-09 07:50:08 UTC
From:
To:
Hi,

The nbd configure.ac contains:

AC_PROG_CC_C99

because I use a number of C99 constructs in the code. When, however, I
run configure like so:

./configure CFLAGS='-g -O0 -Wall -Werror'

because I want to clean up the code a bit, I get an error message at
compile time:

nbdsrv.c: In function 'getmaskbyte':
nbdsrv.c:116:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
  for(int i = 7; i + masklen > 7; i--) {
  ^

which is surprising, since I asked for C99 mode. If I specify CFLAGS so
it also contains '-std=gnu99', then everything compiles cleanly (apart
from the bits that are caused by the -Wall -Werror, that is).

#754268#10
Date:
2014-08-09 15:29:51 UTC
From:
To:
[resending due to wrong @bugs address in last copy, sorry]

Specifying -Werror in CFLAGS to configure is almost always a mistake.
It screws up Autoconf tests, because some Autoconf tests unavoidably
provoke warnings.  Remove -Werror and you'll get better results.