[Top][All Lists]

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

Re: [DotGNU]c compiler: Problems with constants

From: Michal Moskal
Subject: Re: [DotGNU]c compiler: Problems with constants
Date: Tue, 23 Mar 2004 14:56:17 +0100
User-agent: Mutt/1.4.1i

On Tue, Mar 23, 2004 at 07:38:10PM +1000, Rhys Weatherley wrote:
> > main ()
> > {
> >         int i;
> >         {
> >                 /* do nothing*/
> >         }
> >         int j;
> > }
> >
> > I guess this is because cscc assumes that something apart from variable
> > declarations happens inside the subblock - which excludes futher variable
> > declarations i.e. the declaration of j - at the parsing level.  Presumably
> > gcc leaves this check until later when it can see that the subblock
> > contains nothing that is not a variable declaration inside.
> Traditional ANSI C only allows declarations at the head of a block.  C++ 
> allows them anywhere in a block.  The latest version of gcc follows the C++ 
> model.  Until recently, such code was considered invalid in C.

I believe this is C99 model, not C++ one.

> I personally think that it *should* be invalid because it causes sloppy 
> coders 
> to write C code that won't compile on most of the world's existing C 
> compilers, harming code portability in the process.  This is why I do most of 
> my development with gcc 2.x, not gcc 3.x - the resulting C code is more 
> portable.

It warns about it, with -pedantic. IMHO it should treat it as error in
C89 mode, but ...

<flame>Another thing to think about is that C99 is ergh.. 5 years old,
so maybe there is little point in supporting ancient compilers :-)</flame>

: Michal Moskal :: :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?

reply via email to

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