From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Walker To: help-gcc@gnu.org Subject: Re: Declaring variables mid-function Date: Sat, 18 Dec 1999 15:56:00 -0000 Message-id: <5vhARpAQ5BX4EwUB@howgarth.demon.co.uk> References: <385c11fa@oit.umass.edu> X-SW-Source: 1999-12/msg00265.html In article < 385c11fa@oit.umass.edu >, Shawn 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) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Walker To: help-gcc@gnu.org Subject: Re: Declaring variables mid-function Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <5vhARpAQ5BX4EwUB@howgarth.demon.co.uk> References: <385c11fa@oit.umass.edu> X-SW-Source: 1999-12n/msg00265.html Message-ID: <19991231222400.JN7Bd7E7tG4fEtowYr3cD-i9Pi9fTf5OQU4B2TMEmmc@z> In article < 385c11fa@oit.umass.edu >, Shawn 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)