Declaring variables mid-function
Jamie Walker
jamie@sagaxis.co.uk
Sat Dec 18 15:56:00 GMT 1999
In article < 385c11fa@oit.umass.edu >, Shawn <NRLax27@aol.com> writes
> I am writing a medium sized program, and ran into a problem where gcc
>would not compile any function that did not have all of its variables
>declared as the first lines of the function. As a test, I wrote this small
>program:
In standard C, you cannot declare variables part-way through any
function.
Move them to the top of the function and they will compile fine.
C++ does support what you want, so you could rename your .c files to .C
and gcc will treat them as C++, then they should work fine.
HTH,
--
Jamie Walker http://www.sagaxis.co.uk/
"lp1 reported invalid error status (on fire, eh?)", Linux error message
PGP Key ID: 0x1B6BBB15 (available on public key servers)
More information about the Gcc-help
mailing list