Does LINT understand ANSI prototyping?

Karl Heuer karl at haddock.ima.isc.com
Thu Oct 25 13:38:02 AEST 1990


In article <1990Oct24.183836.24082 at portia.Stanford.EDU> rstanton at portia.Stanford.EDU (Richard Stanton) writes:
>Does LINT not understand ANSI prototypes?

Yes it does, but only if you have the latest version of lint (it's in SVR4).
If you only have access to a pre-ANSI lint, you'll have to hide the prototypes
from it.  (I'll assume that there are no ANSIisms other than the prototypes;
if this is not the case you've got more trouble than I can help you with.)

If the only prototypes are in the header files, then I recommend you rewrite
them to look like this:
	#if defined(__STDC__)
	extern set_t mkset(void);
	extern bool is_empty(set_t);
	extern void add_to(void const *, set_t *);
	#else
	extern set_t mkset();
	extern bool is_empty();
	extern void add_to();
	#endif
(Some people prefer to use a single set of declarations with magic macros that
expand into either an empty pair of parentheses or the appropriate arglist; I
don't like that convention.)

In actual source code that you have to maintain, it can be painful and ugly to
support both prototyped and old-style declarations; in this case I prefer to
maintain the code with prototypes and, when the code needs to be viewed by a
pre-ANSI tool, filter it through a deprotoizer.  One such is "unprotoize",
which hangs off of gcc and should be available in the various GNU archives.  I
maintain a less powerful one that's entirely self-contained (available on
request, but it's tuned to my personal coding style).

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list