From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Brendan Murray" To: help-gcc@gnu.org Subject: Re: Declaring variables mid-function Date: Sat, 18 Dec 1999 17:44:00 -0000 Message-id: References: <385c11fa@oit.umass.edu> <5vhARpAQ5BX4EwUB@howgarth.demon.co.uk> X-SW-Source: 1999-12/msg00269.html > { > 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 - once you hit the enclosing "}", fubar's toast. In C, variables have scope only at the level in which they have been declared; in this case that's within the block, not to the end of the function. B= From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Brendan Murray" To: help-gcc@gnu.org Subject: Re: Declaring variables mid-function Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: References: <385c11fa@oit.umass.edu> <5vhARpAQ5BX4EwUB@howgarth.demon.co.uk> X-SW-Source: 1999-12n/msg00269.html Message-ID: <19991231222400.1ViacwUwne2H1qrVu2pV-KZFHfGDewtq6Swcj5KryHc@z> > { > 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 - once you hit the enclosing "}", fubar's toast. In C, variables have scope only at the level in which they have been declared; in this case that's within the block, not to the end of the function. B=