Strange lint mumblings

Guy Harris guy at auspex.UUCP
Fri Dec 16 04:34:28 AEST 1988


 >    exit(0);	/* followed immediately by main's closing brace */
 >
 >causes lint to complain:
 >
 >(137)  warning: main() returns random value to invocation environment

See the other article in comp.lang.c/INFO-C about "incorrect" "lint"
complaints; the problem is the same - "lint" has no idea that "exit"
never returns, and therefore thinks that after it *does* return, "main"
returns by "falling off the end".  This means it doesn't return a value;
in many C implementations, returning from "main" with a particular value
causes the process to terminate with the returned value as its exit
status.  To fix this, either change

	exit(0);

to

	return 0;

(with parentheses added as per local preferences) or add

	/*NOTREACHED*/

after the "exit(0)".



More information about the Comp.lang.c mailing list