exit() and return() in a C program

Dr Gareth J. Barker gbarker at mph.sm.ucl.ac.uk
Wed Aug 8 19:08:02 AEST 1990


Can somebody explain to me what the lint message below means?

	titan% cat test.c
	main()
	{
	}
	titan% lint test.c
	test.c(3): warning: main() returns random value to invocation
	environment
	titan% 
    titan% cat test1.c
    void exit();

	main()
	{
		exit(0);
	}
	titan% lint test1.c
	test.c(6): warning: main() returns random value to invocation environment

Replacing exit by return makes lint happy.

	titan% cat test2.c
	main()
	{
		return(0);
	}
	titan% lint test2.c
	titan% 

Is lint just trying to tell me that any function, including main, must
have at least one 'normal' return?  Is this a new feature in 4.1, I
don't remember seeing this before?

-- 
Gareth J. Barker,
Institute of Neurology, Queen Square,
London, UK.

JANET    : gbarker at uk.ac.ucl.sm.mph
INTERNET : gbarker at .mph.sm.ucl.ac.uk
BITNET   : gbarker%uk.ac.ucl.sm.mph at ukacrl.bitnet



More information about the Comp.sys.sun mailing list