exit() and return() in a C program (SUMM

Dr Gareth J. Barker gbarker at mph.sm.ucl.ac.uk
Mon Aug 13 23:14:49 AEST 1990


The answer to my question :

was that main is implicitely defined as returning an int (since I hadn't
defined it as anything else) and lint therefore wanted to se it return an
int at the end any path through the routine.  Since it doesn't know that
exit() never returns it give an error message when it 'drops off the end'
of the function.  The solution is either to change the code to:

		main()
		{
			exit(0);
			return(0);
		}

where the return() statement will never be reached but will keep lint
happy, or, more cleanly:

		main()
		{
			exit(0);
			/*NOTREACHED*/
		}

Thanks to:
kucharsk at com.solbourne  
cudcv at uk.ac.warwick.cu  
sanzgiri%flamingo.meta  
steve at com.taumet       
cgwst at edu.pitt.cis.uni
guy at com.auspex       
scl at edu.virginia.acc.s  
cs at com.sun.eng         
lwv27 at EARN.CAS        
(David Moore)moore%ess
hue%island at com.sun    

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