[splint-discuss] Parse Error on variable declaration in the middleof a function.

Michael Wojcik Michael.Wojcik at MicroFocus.com
Sat Mar 21 06:49:05 PST 2009


> From: splint-discuss-bounces at cs.virginia.edu
[mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of Johan
> Sent: Saturday, 21 March, 2009 07:38

> I get a Parse error on variable declaration in the middle of a
function.

Splint is mostly a C90 implementation, and in C90 declarations can only
appear at the beginning of a block. Support for some parts of C99 have
been added, but this one is (apparently) not one of them, at least in
the version you have.

Patches to Splint to allow variable declarations elsewhere in a block
have been posted to this list at least as far back as 2006; you can
check the archives.

(Your declaration of main is also incomplete, by the way; it should be
"int main(void)". Incomplete declarations are poor practice and should
not be used in new code, except for the - very rare - case of source
that needs to be compiled as both C and C++.)

-- 
Michael Wojcik
Principal Software Systems Developer, Micro Focus




More information about the splint-discuss mailing list