Subject: bug#7099: mbsalign.c old c compiler complains about variables defined inside code

From: Pádraig Brady <[email-masked]>
Date: Fri, 24 Sep 2010 22:38:37 +0100

On 24/09/10 21:15, Suhan Andrei wrote:
> Hi
> 
> Just wanted to let you know there are some errors when using old compiler 
> (
> gcc -v
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
> gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
> )
> 
> 
> Tere are 2 variables defined inside blocks of code that triggers old c compiler 
> to spill errors.
> I used code from coreutils-8.5.tar.gz 
> I moved declaration at the start of code and all compiled ok.

Eep, I'll fix that up, as we want to keep stuff under gl/
C89 conformant, as it may be moved to gnulib at some stage.

$ LANG=C gcc -std=c89 -pedantic -Werror -c git/coreutils/gl/lib/mbsalign.c -o /dev/null -I git/coreutils/lib/
cc1: warnings being treated as errors
In file included from git/coreutils/gl/lib/mbsalign.c:21:
git/coreutils/gl/lib/mbsalign.h:24: error: comma at end of enumerator list
git/coreutils/gl/lib/mbsalign.c: In function 'mbsalign':
git/coreutils/gl/lib/mbsalign.c:241: error: ISO C90 forbids mixed declarations and code
git/coreutils/gl/lib/mbsalign.c: In function 'ambsalign':
git/coreutils/gl/lib/mbsalign.c:269: error: ISO C90 forbids mixed declarations and code

However I'm confused about how this was the only failure
given this info from README:

***********************
Pre-C99 build failure
-----------------------

There is a new, implicit build requirement:
To build the coreutils from source, you should have a C99-conforming
compiler, due to the use of declarations after non-declaration statements
in several files in src/.  There is code in configure to find and, if
possible, enable an appropriate compiler.  However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
If that happens, simply[*] apply the included patch using the following
command, and then run make again:

  cd src && patch < c99-to-c89.diff

[*] however, as of coreutils-7.1, the "c99-to-c89.diff" file is no longer
maintained, so even if the patches still apply, the result will be an
incomplete conversion.  It's been 10 years.  Get a decent compiler! ;-)

cheers,
Pádraig.