Discussion:
switch to C99 breaks DFA tests
(too old to reply)
Assaf Gordon
2017-01-10 21:27:33 UTC
Permalink
Raw Message
Hello all,

I noticed that some standalone tests now fail because they use c99
constructs.

For example:

./gnulib-tool --create-testdir --dir test1 dfa
cd test1
./configure
make

fails with:
dfa.c: In function ‘fillset’:
dfa.c:727:3: error: ‘for’ loop initial declarations are only \
allowed in C99 mode
for (int i = 0; i < CHARCLASS_WORDS; i++)
^

as a work-around, running with
make CFLAGS="-std=c99"
works fine.

regards,
- assaf
Paul Eggert
2017-01-10 22:40:53 UTC
Permalink
Raw Message
dfa.c:727:3: error: ‘for’ loop initial declarations are only \
allowed in C99 mode
for (int i = 0; i < CHARCLASS_WORDS; i++)
^
Yes, the DFA module uses C99 statement-after-declaration syntax. Awk was
the last dfa-using package that tried to port to C89 compilers, and when
Awk no longer required that we started using that C99 feature and don't
really want to go back.

You ran into a problem because your old version of GCC defaults to
C89ish syntax. We didn't run into the problem because we are either
using newer GCC, or are using the dfa module in a package that tells GCC
to be C99-or-later compatible.

I installed the attached to try to work around the problem.

Possibly we should instead just start assuming C99 everywhere? At least,
the declaration-after-statement part.
Bruno Haible
2017-01-11 21:15:17 UTC
Permalink
Raw Message
Post by Paul Eggert
Possibly we should instead just start assuming C99 everywhere? At least,
the declaration-after-statement part.
A couple of years ago, I objected, because the MSVC compiler did not support
declaration-after-statement. MSVC 14 now supports it.
=> No objection any more.

Bruno

Loading...