Google Grupper har inte längre stöd för nya Usenet-inlägg eller -prenumerationer. Historiskt innehåll förblir synligt.
Dismiss

Problem of using lint to check C++ code

26 visningar
Hoppa till det första olästa meddelandet

Carfield Yim

oläst,
14 okt. 2008 06:40:372008-10-14
till
I get the error saying that

lint: file with unknown suffix ignored: XXX.cpp

How can I deploy some kind of static checking to CPP application?

Pascal J. Bourguignon

oläst,
14 okt. 2008 08:29:372008-10-14
till
Carfield Yim <carf...@gmail.com> writes:

Yes, but not with lint.

There are tools specifically targetted at C++.

For example, lint++ :

alias lint++='g++ -o /dev/null -c -pedantic -Wall -Werror -W'

For example:
$ lint++ vectors.c++
cc1plus: warnings being treated as errors
vectors.c++: In function 'std::vector<A, std::allocator<A> > g(std::vector<A, std::allocator<A> >)':
vectors.c++:25: warning: comparison between signed and unsigned integer expressions
vectors.c++: In function 'void test_vector()':
vectors.c++:34: warning: comparison between signed and unsigned integer expressions

There are also commercial tools such as cpptest.
http://www.parasoft.com/jsp/products/home.jsp?product=CppTest&itemId=47

--
__Pascal Bourguignon__

James Kanze

oläst,
14 okt. 2008 17:36:152008-10-14
till
On Oct 14, 2:29 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:

> Carfield Yim <carfi...@gmail.com> writes:
> > I get the error saying that

> > lint: file with unknown suffix ignored: XXX.cpp

> > How can I deploy some kind of static checking to CPP application?

> Yes, but not with lint.

There are versions of lint which can handle C++ (but I'm not
sure that they're called lint---maybe lint++).

> There are tools specifically targetted at C++.

> For example, lint++ :

> alias lint++='g++ -o /dev/null -c -pedantic -Wall -Werror -W'

That doesn't begin to do everything that lint does. Link looks
at the entire program.

In my experience, however, it's not really necessary for C++,
unless you have people doing really stupid things. So g++ does
nore or less do the job (with the appropriate options). But
given that, there's no real reason not to generate code while
you're at it.

--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Bill Davy

oläst,
15 okt. 2008 05:29:482008-10-15
till
I use PC-Lint from www.gimpel.com and yes, it finds bugs and tightens up
code.

One thing which is often forgotten is that when maintaining a program, it is
useful if things clearly have the minimum coupling. Lint points out when
things can be made static or const or moved out of a header, which is not
the job of a compiler. This helps writers produce the least coupling. As
maintenance is more important and difficult than writing code (and why write
"code", not software), writers should have to produce clean Lint runs before
saying their "code" is done.

Well, that's my opinion.

Bill

PS And yes, I do "really stupid things" but I feel admitting it is a sign of
maturity.


"James Kanze" <james...@gmail.com> wrote in message
news:971b700c-1d26-4ef2...@v16g2000prc.googlegroups.com...

0 nya meddelanden