[comp.lang.c] Does LINT understand ANSI prototyping?

rstanton@portia.Stanford.EDU (Richard Stanton) (10/25/90)

First, sorry about posting what is a somewhat UNIX specific question here,
but I had no response from comp.unix...

I have a multipart program which I developed under DOS and VMS. I recently
gained access to a UNIX system, so tried to use LINT on the whole thing,
only to have it choke horribly on my header files, which use full ANSI
prototyping (double func(double t) etc).

The system here runs Ultrix V3.1C, if that's important. 

Does LINT not understand ANSI prototypes? Is there a way of setting flags
so that it does, or do I need to rewrite my header files (if so, what is the
preferred way of doing this? I'd like to keep the full prototypes as they are,
if possible).

Thanks for any suggestions

Richard Stanton
pstanton@gsb-lira.stanford.edu

karl@haddock.ima.isc.com (Karl Heuer) (10/25/90)

In article <1990Oct24.183836.24082@portia.Stanford.EDU> rstanton@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@ima.isc.com or uunet!ima!karl), The Walking Lint