Subject: Re: lint doesn't define __STDC__?
To: Johan Wall?n <email@example.com>
From: David Holland <firstname.lastname@example.org>
Date: 11/07/2007 21:59:42
On Wed, Nov 07, 2007 at 08:32:28PM +0200, Johan Wall?n wrote:
> I have for a long time had a confusion about lint, and this might be a
> good occation (although it is off-topic) to ask: should not lint be an
> obsolete tool? A C compiler should have more information available, so
> it should be able to do all the checks lint does and more? In an ideal
> world, at least.
Yes and no - while the front ends of a lint and a C compiler do
essentially the same work, and even downstream from that some of the
analyses are the same, it's not automatically clear that they should
therefore be the same program. A compiler, for example, is constrained
to behave like a compiler and emit .o files one at a time, whereas a
lint can emit other things, set up and maintain a database, or
whatever. This means it can be much more aggressive about inter-module
analysis. (And, as Christos pointed out, ours already is.)
A lint can also (although I don't think ours does) work from a
specification of the C standard library rather than the system include
files, which lets it "know" things a compiler can't so easily. It also
doesn't have to generate code, so it can do simplifications or
abstractions on the input that would be problematic in a compiler;
this at least potentially allows it to do broader analyses without
taking unreasonably long to finish.
Nonetheless, I don't really have the impression that the lint we have
in base is any smarter than gcc.
- David A. Holland / email@example.com