1

I'm trying to configure cppcheck-vs-addin to automatically check my code on save. So far, so good. However, when I run it on my whole project, I want to exclude several folders (containing sources and headers I have no control on).

Files im trying to exclude are in folder libs\something\files.* Folder tree is something like

src | Folder A | Folder B libs | LibsA | LibsB 

What I have tried so far :

-In settings, I added -ilibs to the additionnal arguments field

-In Edit solution suppressions / Excluded include path : .*\\libs\\.* (this should work for headers file, but I also have source files)

-In Edit solution suppressions / Files excluded from check .*\\libs\\.* (this option only seem to work on file name, not on the containing folder, so in this case it does nothing)

Additionnal question, is it possible to view the cppcheck.exe command that is run? It could help understanding what im doing.

1 Answer 1

1

If you have installed CPPCheck (and that it is on it's default location), add the path C:\Program Files (x86)\Cppcheck to Environment variable. Now update your pre build events from your project property and invoke cppcheck directly from there. Check this image how you can specify PreBuild Events

Visual Studio C++ Project Property Page to setup Pre-Build Event

Now you can provide argument to exclude directory (like any third party code etc.) from scan.

cppcheck --project=$(MSBuildProjectFullPath) -i "$(ProjectDir)foo\src\" --output-file="$(OutDir)$(TargetName).xml" 

--project=$(MSBuildProjectFullPath) selects your current project file (.vcproj or .vcxproj) file,

-i Specifies the directory you want to exclude from scan

--output-file="$(OutDir)$(TargetName).xml" creates the output file in project output directory with analysis results.

To see detail argument list, type cppcheck --help in your command line.

Sign up to request clarification or add additional context in comments.

1 Comment

This workaround should work, you're basically calling cppcheck natively, but you're completely bypassing the addin. So we dont have the error display inside the IDE

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.