Declaring variables mid-function
Arthur Gold
agold@bga.com
Tue Dec 21 09:19:00 GMT 1999
bowman wrote:
>
> Jamie Walker <jamie@sagaxis.co.uk> 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<bar; 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.
More information about the Gcc-help
mailing list