Prototypes, was Why NULL is 0

Tom Stockfisch ix426 at sdcc6.ucsd.EDU
Sat Mar 19 13:38:37 AEST 1988


In article <25699 at cca.CCA.COM> g-rh at CCA.CCA.COM.UUCP (Richard Harter) writes:
>
>	As it stands, the real value of a prototype is informative --
>the calling routine can contain a description of a calling sequence.
>Its value for protecting against erroneous usage of routines is nominal;
>lint is really much more useful.  A prototype declaration does not protect
>you against an incorrect prototype declaration because it does not 'look'
>at the real master (the actual declaration in the code in the called routine)
>whereas lint does.


The prototype DOES protect you against incorrect declaration if you put it
in a header file that is included in BOTH the caller function file AND the
callee function file.  The compiler will then complain of an incompatable
re-declaration if the header file is out of sync with the definition.
This is much preferable to re-linting after every change to a prototype.
It avoids the quadratic behavior of the following sequence:
	
	vi f1.c
	lint f1.c
	cc f1.c

	vi f2.c
	lint f1.c f2.c
	cc f1.o f2.c

	vi f3.c
	lint f1.c f2.c f3.c
	cc f1.o f2.o f3.c

	...

If you cut out the lint, the only remaining quadratic portion is in the loader.
Of course, you'll still want to run lint every great once in a while to check
other things (like conversion of function pointers, or long identifier clashes,
or unreachable code).
-- 

||  Tom Stockfisch, UCSD Chemistry   tps at chem.ucsd.edu



More information about the Comp.lang.c mailing list