Domanda

My company has the PC-lint executable lint-nt.exe.

I am trying to use this to integrate PC-lint with MS Visual Studio 2008 to analyze .c/.cpp sources. But I have no success with getting that to work.

I read:

http://www.gimpel.com/html/pub80/env-vc9.lnt

and similar such info on one or two other sites, but no success.

I followed the indicated steps to add an external tool in Visual C++ 8, but when I click on the newly added tool, the pc-lint window opens momentarily and is closed immediately, and I doubt it has run any analysis. So its not working for me.

Then I tried running lint-nt.exe on a windows command prompt as

lint-nt.exe +fce +fcp +cpp(cpp,cxx,cc) -i"C:\Program Files\Microsoft Visual Studio 9.0\VC\include" +libdir +libh myfile.cpp

It did perform the analysis but it analyzed a lot of header files from the Visual C++ INCLUDE folder (limits.h sal.h iostream etc..), because my source file had #include <iostream> and so on.

EDIT: I see pc-lint has options +/-libdir, +/-libh and such options, which might help, but I just could not use them correctly to avoid the analysis of compiler headers.

Two questions:

  1. How do I prevent pc-lint from analyzing the compiler header files and only analyze my source code files?
  2. How to integrate pc-lint into Visual C++ 2008 Express edition, which I am using?
È stato utile?

Soluzione

If your company has the Lint executable, it will also have the PC-Lint manual in PDF form if not on paper. It is delivered on the CD-ROM together with the executable. That manual is your friend, to figure out how to use all the many options available.

To your question:

  1. To get started quickly, remove the +fce, +fcp, +libdir and +libh options from your command line. I suppose you are just missing the -wlib(1) option to remain silent about the many warnings the MS libraries produce. Do not use -wlib(0): You will have silenced all options for the library headers, but incorrect configurations originating in those library headers may produce a truckload of warnings in your code where you could not find the culprit hidden in those compiler headers.
  2. The link of user34341 is not a bad start, although I have some problems following along precisely. And the env-vc9.lnt from the Gimpel website assumes that you have installed PC-lint with their installer. Reading between the lines of your question, I guess you have not. The details of creating such an installation including the generation of the PC-lint option file std.lnt take us too far for this answer, but I have written a PDF document "How to wield PC Lint" explaining this all in painful detail. If you combine the link from user34341, the options file from Gimpel and my document, you should be OK.

Furthermore: The env-vc9.lnt only contains the option for using the VC9 environment (a.k.a Visual Studio); to support the C/C++ compiler you'll need the appropriate compile option file http://www.gimpel.com/html/pub80/co-msc90.lnt and its associated (Lint-only) header file http://www.gimpel.com/html/pub80/co-msc90.h.

So before you start integration in VS2008, download them and try this command line:

lint-nt.exe +cpp(cpp,cxx,cc) co-msc90.lnt myfile.cpp

and see if the results are better than before. The -ioption was OK, but if you have the environment variables (e.g. %INCLUDE%) set up correctly for Visual Studio, it shouldn't be necessary.

And one more hint: Assuming you have not done so already, look at the version of PC-lint you have available, and make sure to update to the latest patch level: 7.50ad, 8.00x, 9.00i (current version); the links under the version numbers take you to the appropriate website page. It will save you a lot of trouble. I know that getting the latest version is not always an option, even if highly preferable.

Altri suggerimenti

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top