From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arthur Gold To: help-gcc@gnu.org Subject: Re: Declaring variables mid-function Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <385FB63D.EA7143FA@bga.com> References: <385c11fa@oit.umass.edu> <5vhARpAQ5BX4EwUB@howgarth.demon.co.uk> X-SW-Source: 1999-12n/msg00287.html Message-ID: <19991231222400.YbLAcwNRQj1JkZDZn1IkZa1MWGF05Hlc5LCYYyvpcjU@z> bowman wrote: > > Jamie Walker wrote: > > >In standard C, you cannot declare variables part-way through any > >function. > > I won't stick my neck out and say it is standard, as I don't have > Harbison & Steele handy, but gcc will accept declarations at the > head of any block. So > > int foo() > { > int bar; > bar = 1234; > { > int fubar; > for (fubar=0; fubar printf("completely fooed\n"); > } > } > > should compile. I believe that fubar is at least lexically visible to the > end of the function, unlike some languages where the scope would be strictly > the block. Nope. Strictly the block. HTH, --ag > > Comments from the language lawyers are welcome on what exactly the standard > stipulates are welcome. -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info) mailto:agold@bga.com or mailto:agold@cs.utexas.edu -- A: Look for a lawyer who speaks Aramaic...about trademark infringement.