[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [POLL] C99, declaration after statement

From: Pádraig Brady
Subject: Re: [POLL] C99, declaration after statement
Date: Sun, 25 Sep 2011 14:25:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 09/25/2011 09:14 AM, Gary V. Vaughan wrote:
> Hi Paul,
> On 25 Sep 2011, at 13:09, Paul Eggert wrote:
>> On 09/24/11 22:31, Gary V. Vaughan wrote:
>>> $ cc -o hello hello.c
>>> cc-1241 cc: ERROR File = hello.c, Line = 7
>>>  A declaration cannot appear after an executable statement in a block.
>> You're supposed to use cc's -c99 flag, no?
>> Or compile with c99?  Then declarations after statements
>> should work; see, for example
>> <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00241.html>.
> D'oh!  Quite right.
> There must be some side effect that -c99 has which prevents me from just
> turning it on indiscriminately... Unfortunately I don't remember what, only
> that I've had to go through adding braces to make extra scopes around out
> of order declarations.
> I'll keep an eye out for an example and post it here when I find it.
>> Is 'configure' not doing this for you automatically?
>> If so, then let's fix that.
> How will configure know whether it needs to use -c99 mode or not?  I tend
> to set CC and CFLAGS per host/compiler pair anyway, so I wouldn't notice
> if configure is trying to pick the flags for me.
> Cheers,

AC_PROG_CC_STDC should try to enable C99 first and then C89
There is also AC_PROG_CC_C99, since autoconf 2.59c (Apr 2006).
If doing this in gnulib we should also remove the
-Wdeclaration-after-statement from m4/manywarnings.m4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]