(* func)(fred, bert)

RAMontante bobmon at iuvax.cs.indiana.edu
Tue Nov 28 05:21:28 AEST 1989


excerpted from jon at jonlab.UUCP (Jon H. LaBadie) <824 at jonlab.UUCP> :
-I encountered one instance where "declaring" main to be other than int
-caused severe problems.  The file containg main was organized as follows:
-    struct foo {
-	various members;
-    }
-
-    main()
-    {
-	...
-    }
-Note the missing semicolon, failing to terminate the declaration of
-struct foo, and thus serving to define main as a function returning a
-struct foo.


Sounds like an argument for explicitly stating the return type (of
main() and all other functions) --- the missing paren would've tripped a
syntax error.  Of course that would tempt you to declare a type that
reflected what you expect main() to return, like "void" ...

Maybe stdlib.h or something should've included a standard prototype:
	int main(int, char **, char **);
to clean up stuff like this.



More information about the Comp.lang.c mailing list