Why does lint foul up on #if 0

ok at edai.UUCP ok at edai.UUCP
Thu Jan 19 23:23:30 AEST 1984


I like putting great big block comments in my C programs.
I like putting examples of how to use various things in those comments.
And of course well-written examples are commented.
So the scheme I use is

#if	0				/* COMMENT */

    ... lots of text ...
    ... bits of C code, which can safely use /* comments */
    ... lots of text ...

#endif	0				/* COMMENT */

    The two lines starting with a sharp are precisely what I type.

    Now I have used 6 different C compilers on 4 different kinds of
machines, and all but the version 6+ PDP-11 C pre-processor were
quite happy with it.  In v6+ I had to say #ifdef COMMENT and be very
very careful never to define COMMENT.

    As a careful programmer, I would like to use "lint".  BUT lint
evidently thinks 0 is true, and TRIES TO COMPILE MY COMMENTS!!!!
I have put together an interface to lint that shoves all the files
through the preprocessor (courtesy of "cc -E"), but it tends to tie
up file space and from time to time I forget to use it.

    Can anyone tell me
(a) why "lint" does something so very different from /lib/cpp with #if 0
(b) whether there is an easy way to tell it not to
(c) whether System III/System V "lint" is this stupid (there must be
    *some* reason why people get S3 instead of 4.1).



More information about the Comp.lang.c mailing list