Advertisement

lint-like tool for C++

Started by May 19, 2000 08:40 AM
6 comments, last by Altmann 24 years, 6 months ago
Hi, Does anyobody know of a free lint-like tool for C++ ? I''d prefer if it were for linux but I can survive with a Windows or even a Macintosh version. For those of you who do not know lint, it is a tool which checks source codes for ansi compliance, for a big range of common mistakes (error 777 : == used to compare floats) and for some style aberrations. Thanks, David P.S. : Firahs, this was not an attack against Macintosh.
Sorry, I don''t know about a lint-like tool, but I was wondering about the "error 777 : == used to compare floats". If you can''t use == to compare floats, how do you compare floats?

/. Muzzafarath
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
You don''t compare floats at all : with numerical deviation, (a+1)-1 == a returns false.

What you can check is if two floats are close. In order to do this, you define an epsilon and you check if [a-epsilon, a+epsilon] and [b-epsilon, b+epsilon] intersect.

Be reading you,
David
Last I checked (but this was years ago), C++ was considered to be such a horribly structured language that any prototype version of lint++ died in a horrible painful death.

Consider for example this template example:
list <list<int >> l;

This is clearly a list of list of ints. However any parser with the same rigour of lint would barf when it saw >>.

Edited by - SiCrane on May 19, 2000 1:22:37 PM
LCLint is a free lint for Windows and Linux. You can find it at http://lclint.cs.virginia.edu/
Yes, I already checked. It only does C.

Thanks anyway
Advertisement
quote: Original post by SiCrane

Consider for example this template example:
list <list<int >> l;

This is clearly a list of list of ints. However any parser with the same rigour of lint would barf when it saw >>.


I thought, to be honest, that this would throw up a compilation error anyway, the idea being that you need a space to separate it? Perhaps compilers are intelligent enough to work around this but I would have thought the language demanded whitespace?
Yep, that''s what''s written in the standard.
However, I believe that CodeWarrior 5.3 and gcc 2.95.2 both understand the mistake and produce a readable error message.

This topic is closed to new replies.

Advertisement