Problem of using lint to check C++ code

C

Carfield Yim

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?
 
P

Pascal J. Bourguignon

Carfield Yim said:
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 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
 
J

James Kanze

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.
 
B

Bill Davy

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.


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,459
Latest member
Vida00R129

Latest Threads

Top