Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!murtoa.cs.mu.oz.au!munnari.oz.au!uqcspe!hitech!clyde
From: clyde@hitech.ht.oz (Clyde Smith-Stubbs)
Newsgroups: comp.lang.c++
Subject: Re: declaration problem
Message-ID: <311@hitech.ht.oz>
Date: 14 Aug 89 05:43:30 GMT
References: <534@atcmpe.atcmp.nl>
Organization: HI-TECH Software, Brisbane, QLD, Australia
Lines: 28

From article <534@atcmpe.atcmp.nl>, by leo@atcmp.nl (Leo  Willems):
> 	main(){
> 		int x;	
> 		function(int,int,int);		// mark
> 		int y;
> 
> 		function(1,2,3);
> 	}
> 
> The marked line is flagged with a syntax error. Prepending `int' on that line
> takes away the problem as expected.

The reason that the compiler flags an error in this example is that it
sees function( and presumes it to be a function call! It is necessary to
place an explicit type specifier in front to ensure the compiler
knows this is a declaration, not a statement. Where such a declaration
occurs outside a function there is no ambiguity since a statement may
occur only inside a function.
Now for one of my hobby horses; putting extern declarations inside functions
is a Bad Thing. It prevents the compiler checking your declaration against
other declarations of the same thing, and serves no useful purpose anyway.
Always put ALL extern declarations at the global level, i.e. outside
any function.
-- 
Clyde Smith-Stubbs
HI-TECH Software, P.O. Box 103, ALDERLEY, QLD, 4051, AUSTRALIA.
INTERNET:	clyde@hitech.ht.oz.au		PHONE:	+61 7 300 5011
UUCP:		uunet!hitech.ht.oz.au!clyde	FAX:	+61 7 300 5246