Domanda

I am using PC-Lint for my C++ project. Is there a way to switch off all error and warning messages by default, so I can then reintroduce the required messages explicitly?

I have read the chapter of the PC-Lint manual entitled "Error Inhibition Options" and the best I could find was setting the wLevel to -w0 No messages (except for fatal errors)

È stato utile?

Soluzione

Yes, it is possible, you can simply use -e* or -w0. However, the manual truly states (Chapter 16. Living with Lint):

DO NOT simply suppress all warnings with something like: -e* or -w0 as this can disguise hard errors and make subsequent diagnosis very difficult.

So, yes, you can use it if your code is basically cleaned, and you want to review recent changes for a certain set of messages. But if you want to start cleaning your code, and are swamped with messages because of the default warning level -w3, I suggest to start using -w1, and resolve all issues there; most of the warnings/errors given at level one indicate problems with finding all header files, having al implicit macros set properly, and/or mimicking the compiler you use normally in a sufficiently precise way.

As always, I hesitate to advertise my own work, but if you want, take a look at my "How to wield PC Lint" PDF, where I have documented detailed instructions to handle the initial deployment of PC Lint and tackling the many warnings/errors/infos/notes you may be buried under.

Altri suggerimenti

When I started introducing PC-Lint to a new project I did the following:

  1. As suggested by Johan Bezem, ran a -w1 level check over the whole thing. This doesn't actually find any new problems, but checks that your program is syntactically valid and finds any configuration issues. Nothing major, assuming your project compiles already.

  2. Run the test again with -w2 level. This found 53,000 issues, which was a bit much to tackle in one go.

  3. Pick a typical bad file, then suppress any errors that seem irrelevant or non-urgent (eg. error 525: (Warning -- Negative indentation from line xxx) adding -e525 to the command line or config file, until you find one that seems serious. In my case this was error 442: (Warning -- for clause irregularity: testing direction inconsistent with increment direction), i.e. a 'for' loop that looked like it should be counting up was actually counting down.

  4. Reset the test level back to -w1 but added in the critical problem by number, -w1 +e442 in this case. Re-run it over the whole project then fix all the instances of that problem.

  5. Back to stage 2 and try again.

This combination of fixing actual problems and suppressing likely false alarms soon gets your numbers under control.

So that everything gets better over time we also implement a script that does a thorough (full -w2 or -w3) check on any files that are created or modified.

I also found the tool LintProject very helpful as it can do an entire Visual Studio solution in one go, with tables with numbers of errors and worst offenders!

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