Beware the implicit function declaration!

john ralls jrll at Portia.Stanford.EDU
Sun Nov 20 15:09:42 AEST 1988


Unless I misunderstand completely the rules on declaration, simply by
defining the functions before main(), they were also declared.  C
defaults to an int return value, so as long as he didn't try to assign
the return value to something else, he got no warnings.  Incidentally,
since these functions niether take nor return any value, they should be
prototyped or declared as void a(void).  This can be done in the body of
main() iff main() is the first function in the file or is in another
file (in which case it should be extern void a (void)) (this is
prototyping);  otherwise the start of the definition should be the
declaration as well.
John



More information about the Comp.lang.c mailing list