C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Code analyzer

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Vivien Mallet
Guest





PostPosted: Mon Aug 25, 2003 9:12 am    Post subject: Code analyzer Reply with quote



Is there a good free tool to analyze a C++ code (syntax errors, common
mistakes, ...)?

Example in Fortran 77: ftnchek ([url]http://www.dsm.fordham.edu/~ftnchek/)[/url].


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Ralf Schneeweiß
Guest





PostPosted: Tue Aug 26, 2003 12:42 am    Post subject: Re: Code analyzer Reply with quote



Yes, you can use PCLint for a static code analysis.

Ralf Schneeweiß
http://www.oop-trainer.de


"Vivien Mallet" <Vivien.Mallet (AT) ecl2002 (DOT) ec-lyon.fr> schrieb im Newsbeitrag
news:3F493D4A.7080300 (AT) ecl2002 (DOT) ec-lyon.fr...
Quote:
Is there a good free tool to analyze a C++ code (syntax errors, common
mistakes, ...)?

Example in Fortran 77: ftnchek ([url]http://www.dsm.fordham.edu/~ftnchek/)[/url].



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Greg P.
Guest





PostPosted: Tue Aug 26, 2003 8:29 am    Post subject: Re: Code analyzer Reply with quote



"Ralf Schneeweiß" <ralf.schneeweiss (AT) onlinehome (DOT) de> wrote

Quote:
Yes, you can use PCLint for a static code analysis.

There is a free Lint utility at:
http://www.splint.org/


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Tue Aug 26, 2003 6:45 pm    Post subject: Re: Code analyzer Reply with quote

In article <1061876008.944257 (AT) cswreg (DOT) cos.agilent.com>, Matt Trentini
<matt_trentini (AT) agilent (DOT) com> writes
Quote:
As I recall though, PCLint (http://www.gimpel.com/) is far from freeware...
Though by all accounts it's a great tool.

OTOH PCLint++ is an excellent tool and identifies a very great number of
dubious if not downright erroneous code statements. The biggest values
IMO are that it does cross TU analysis and supports use of comments to
suppress diagnostics. I.e. if you have looked at an issue it raises and
decide that the code is correct you can sign off on it with a comment
and so document the fact that the code has been checked.

Quote:

Unfortunately, we make do by configuring our compiler (Visual Studio) so
that it outputs many warnings that are off by default. Although it doesn't
give us the coverage that PCLint would it does help somewhat.

Sorry, but that does not get even close to what PCLint++ can achieve.

Quote:

The only problem is that many (many!) warnings are produced within some of
the libraries we use (including the Standard Library) so that it masks a lot
of the 'real' warnings.

That is far from the only problem. Visual Studio just does not provide
anything like the same range of error detection and lacks any simple way
to suppress false positives.

Quote:

Anyone else know of freeware tools? I've been keeping an eye out for ages
but no luck...

Possibly because the cost of PCLint++ is quickly recovered in a
professional environment (actually the real cost is in learning to use
it effectively rather than in the licence fee) I guess you have already
paid many times the cost of PCLint++ in wasted time looking for the real
problems in a plethora of nit-picking diagnostics.

Look at the total development cost, not just the cost of licence fees.
Save 1 day of programmer time and you have recovered the cost of a
PCLint++ licence.

--
Francis Glassborow ACCU
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Bob Archer
Guest





PostPosted: Wed Aug 27, 2003 9:03 am    Post subject: Re: Code analyzer Reply with quote

In article <3F493D4A.7080300 (AT) ecl2002 (DOT) ec-lyon.fr>,
[email]Vivien.Mallet (AT) ecl2002 (DOT) ec-lyon.fr[/email] says...
Quote:
Is there a good free tool to analyze a C++ code (syntax errors, common
mistakes, ...)?

On a similar theme, has anyone tried GCC-XML?

http://www.gccxml.org/HTML/Index.html

It uses the GCC C++ parser and generates an XML description of a C++
program. It looks as though it would be a good base for building a more
sophisticated analysis tool.

Bob


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Tarjei Knapstad
Guest





PostPosted: Wed Aug 27, 2003 9:11 pm    Post subject: Re: Code analyzer Reply with quote

Bob Archer wrote:
Quote:
In article <3F493D4A.7080300 (AT) ecl2002 (DOT) ec-lyon.fr>,
[email]Vivien.Mallet (AT) ecl2002 (DOT) ec-lyon.fr[/email] says...
Is there a good free tool to analyze a C++ code (syntax errors, common
mistakes, ...)?

On a similar theme, has anyone tried GCC-XML?

http://www.gccxml.org/HTML/Index.html

It uses the GCC C++ parser and generates an XML description of a C++
program. It looks as though it would be a good base for building a more
sophisticated analysis tool.


I've had the same thought until I realised that GCC-XML currently does
not dump function bodies to XML which renderes it pretty much useless
for this purpose in it's present state. See:
http://www.gccxml.org/HTML/FAQ.html

Regards,
--
Tarjei


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
kanze@gabi-soft.fr
Guest





PostPosted: Thu Aug 28, 2003 10:38 am    Post subject: Re: Code analyzer Reply with quote

Francis Glassborow <francis (AT) robinton (DOT) demon.co.uk> wrote


[...]
Quote:
Look at the total development cost, not just the cost of licence fees.
Save 1 day of programmer time and you have recovered the cost of a
PCLint++ licence.

This is certainly true in a professional environment (although it is
curiously often very difficult to impose -- tools and programmers'
salaries come from different parts of the budget). But not all C++
programmers are professionals -- at least in the French speaking
newsgroup, there are also students. And given how much most students
earn, licencing costs can soon become a real issue. (It's a point I
often forget myself, given the number of years it's been since I was
last a student.)

--
James Kanze GABI Software mailto:kanze (AT) gabi-soft (DOT) fr
Conseils en informatique orientée objet/ http://www.gabi-soft.fr
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, +33 (0)1 30 23 45 16

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Markus Nullmeier
Guest





PostPosted: Thu Aug 28, 2003 10:46 am    Post subject: Re: Code analyzer Reply with quote

with a recent GCC,
c++ -ansi -pedantic -Wall
helps, but not enough.

On Linux, you can use the Intel 7.1 compiler for no
monetary costs, featuring a high-quality EDG C++ front end.
Code that passes
icc -ansi
has a reasonably high likelihood to be at least valid C++.
Time an again just oversights while coding result in
non-conforming code that is accepted by the compiler
one happens to use.
icc also features an option for "remarks" (-w2) which I find
less useful.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Timo Geusch
Guest





PostPosted: Thu Aug 28, 2003 7:53 pm    Post subject: Re: Code analyzer Reply with quote

Matt Trentini was seen penning the following ode to ... whatever:
Quote:
As I recall though, PCLint (http://www.gimpel.com/) is far from freeware...
Though by all accounts it's a great tool.

It's a great tool, and one that's often underrated. And I can't
remember the Windows version being *that* expensive. However I must
admit that I've failed to convince Those Who Hold The Pursestrings at
several previous employers...

Quote:
The only problem is that many (many!) warnings are produced within some of
the libraries we use (including the Standard Library) so that it masks a lot
of the 'real' warnings.

Write a filter to remove the 'unreal' warnings? I seem to remember
that someone wrote a decoder for VC's standard library messages, maybe
you can create something similar that supresses the warnings in the
library code.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Thu Aug 28, 2003 8:38 pm    Post subject: Re: Code analyzer Reply with quote

In article <d6652001.0308270626.7b754f42 (AT) posting (DOT) google.com>,
[email]kanze (AT) gabi-soft (DOT) fr[/email] writes
Quote:
Francis Glassborow <francis (AT) robinton (DOT) demon.co.uk> wrote in message
news:<jWMdRtDZQyS$Ewx2 (AT) robinton (DOT) demon.co.uk>...

[...]
Look at the total development cost, not just the cost of licence fees.
Save 1 day of programmer time and you have recovered the cost of a
PCLint++ licence.

This is certainly true in a professional environment (although it is
curiously often very difficult to impose -- tools and programmers'
salaries come from different parts of the budget). But not all C++
programmers are professionals -- at least in the French speaking
newsgroup, there are also students. And given how much most students
earn, licencing costs can soon become a real issue. (It's a point I
often forget myself, given the number of years it's been since I was
last a student.)

That was the reason that I very carefully qualified the advice as
concerned with professional programmers. When it comes to students
several other issues arise:

1) There code is often small enough to be properly inspected (were I
responsible for students I would require code inspections as part of the
student's work, possibly including critiques of anonymous code)

2) I have always found Gimpel Software to be a highly responsive firm
and I think any academic institution that approached them would find
them very helpful with licences restricted to strict student only use --
not least because this would create future programmers who would expect
PC-Lint++ or an equivalent tool to be part of the tool set provided by
their employers. Note the FlexeLint provides a portable version suitable
for use in non-MSWindows environments.

3) Even hobbyist programmers might find that the increased productivity
and the reduction in desk thumping merited purchasing a copy of
PC-Lint++. They would find they spent more time writing productive code
and less time in frustrating debugging. I wonder if Jim has considered
releasing a low cost non-commercial version, perhaps the previous
release discounted by the cost of upgrading it to the current release?

--
Francis Glassborow ACCU
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Fri Aug 29, 2003 11:24 am    Post subject: Re: Code analyzer Reply with quote

In article <1062060307.432962 (AT) cswreg (DOT) cos.agilent.com>, Matt Trentini
<matt_trentini (AT) agilent (DOT) com> writes
Quote:
o I can't seem to find a way to download a trial of the product to learn
how to use it - management may be swayed if they see the results (OK, I
should email them requesting one, and haven't done so yet).

Email Gimpel Soft, they are a small company and very accommodating.
Obviously they need to sell their products but they are way above
average in helping customers both real and potential.


--
Francis Glassborow ACCU
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Randy Maddox
Guest





PostPosted: Sat Aug 30, 2003 2:30 am    Post subject: Re: Code analyzer Reply with quote

"Matt Trentini" <matt_trentini (AT) agilent (DOT) com> wrote

Quote:
As I recall though, PCLint (http://www.gimpel.com/) is far from freeware...
Though by all accounts it's a great tool.

Unfortunately, we make do by configuring our compiler (Visual Studio) so
that it outputs many warnings that are off by default. Although it doesn't
give us the coverage that PCLint would it does help somewhat.

The only problem is that many (many!) warnings are produced within some of
the libraries we use (including the Standard Library) so that it masks a lot
of the 'real' warnings.

This is a well-known problem with VC++: If you turn up the warning
level high enough to be useful then you are swamped with warnings in
the VC++ standard headers. The solution is to turn the warning level
up on your code, and turn it down when including VC++ headers, as
shown here:


// warning level is high here

#include <your_header>
#include <your_other_header>

#if defined(_MSC_VER)
#pragma warning (push, 2) // set warning level lower
#endif

#include <map>
#include <list>
#include <string>

#if defined(_MSC_VER)
#pragma warning (pop) // restore previous higher warning level
#endif

// warning level is high again here

This seems to work well enough for me, but is still not a substitute
for lint and its cousins. At least it does allow regular compilation
with a useful warning level.

Randy.


Quote:

Anyone else know of freeware tools? I've been keeping an eye out for ages
but no luck...

Cheers,
Matt

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ziv Caspi
Guest





PostPosted: Sat Aug 30, 2003 1:17 pm    Post subject: Re: Code analyzer Reply with quote

On 25 Aug 2003 05:12:44 -0400, Vivien Mallet
<Vivien.Mallet (AT) ecl2002 (DOT) ec-lyon.fr> wrote:

Quote:
Is there a good free tool to analyze a C++ code (syntax errors, common
mistakes, ...)?

IIRC, PREfast is available as part of the Windows DDK (of all the
places!) It's a "lite" static analysis tool that is used by virtually
all C++ programmers in Microsoft.

Ziv


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Greg P.
Guest





PostPosted: Sat Aug 30, 2003 7:56 pm    Post subject: Re: Code analyzer Reply with quote

Oops sorry, my reference to splint (which is for C) was for off. sorry again

"Greg P." <no (AT) spam (DOT) sam> wrote

Quote:
"Ralf Schneeweiß" <ralf.schneeweiss (AT) onlinehome (DOT) de> wrote in message
news:bidfi9$8699m$1 (AT) ID-204215 (DOT) news.uni-berlin.de...
| Yes, you can use PCLint for a static code analysis.

There is a free Lint utility at:
http://www.splint.org/

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.