Re: [hatari-devel] Some findings

[ Thread Index | Date Index | More Archives ]

On 2018-09-03 18:51, Nicolas Pomarède wrote:
> Hi
> Can't tell the reason for Troed's build ,

I've had a look at the build.log, and it failed during linking, not
during compiling.

> but I fixed a "for loop" in
> nc5380.c that required c11 or c99 options in gcc :
> src/ncr5380.c:309:5: erreur: 'for' loop initial declarations are only
> allowed in C99 or C11 mode
>      for (int i = 0; i < 8; i++) {
>      ^
> src/ncr5380.c:309:5: note: use option -std=c99, -std=gnu99, -std=c11 or
> -std=gnu11 to compile your code
> gcc 4.9.2 is reporting this error, but the most recent gcc 8 doesn't
> report it anymore.

That's an issue indeed - and it happens almost each time we copy some
code from a C++ project to Hatari. The problem is that GCC switched the
default setting for -std, it used to be gnu89, but since GCC 5.1, it is
gnu11 instead.

> Since we want to keep C compatibility with older compilers, maybe we
> should explicitely add options to Cmake in order to report this also
> with more recent gcc ? Using the -std=option (but I don't know the
> equivalent that was used in gcc 4.9) ; else the compilation issue might
> go unnoticed as I guess most of us are compiling with recent gcc version.

I agree, we should set a value for -std in our CMakeLists.txt. The
question is: Which one? Do we want to enforce the old C syntax? Then we
should go with "-std=gnu89". Or are we fine allowing the newer syntax
now, too, especially with regards to the code that we copy from C++
projects? Then we should go with gnu99 or gnu11 instead. I personally
tend to use one of the last options to allow the newer syntax. Shall we
simply have a try with gnu11? It is marked as "incomplete" in GCC 4.x,
but at least for the "for"-loop initializers, it seems to work fine.


Mail converted by MHonArc 2.6.19+