5

Cppcheck scans all files in a project folder:

c:\projectfolder\main.c c:\projectfolder\file.c c:\projectfolder\file.h c:\projectfolder\file_test.cc 

c:\projectfolder\file_test.cc contains the following code

#include "c:/gtest/gtest.h" extern "C" { #include "TMyStruct.h" } TEST(Stack, Overflow) { TMyStruct unterTest; EXPECT_EQ(1, TMyStruct_Init(&unterTest)); EXPECT_GE(unterTest.variable, 9000); } 

File file_test.cc includes the gtest.h file

C:\gtest\gtest.h 

All files in C:\gtest\ should not be tested.

I call

cppcheck.exe -ic:\gtest\ c:\projectfolder\ --enable=style --template="SomeError" 

Errors are found and reported in c:\projectfolder\file_test.cc coming from the included gtest.h (detail: "too many #ifdef configurations").

How do I tell Cppcheck to not look at C:\gtest\gtest.h at all?

2 Answers 2

13

I am a Cppcheck developer. I don't think you can skip a header file. Perhaps it should work like that.

Feel free to create a ticket about this: http://sourceforge.net/apps/trac/cppcheck/

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

7 Comments

I would love to write /*ccpcheck::startignore*/ ... /*ccpcheck::endignore*/
I think that would be acceptable. I added a ticket (sourceforge.net/apps/trac/cppcheck/ticket/4377). I can't promise that we'll fix the ticket soon.. so if you have the time feel free to take a look at it.
Any progress on this feature?
According to the manual (cppcheck.sourceforge.net/manual.pdf) page 7 states that the i option can be used to ignore files.
Nevermind, I was mistaken, -i is only for source files.
|
4

My project structure looks like this:

├── build ├── lib │ └── dep │ └── dep.h ├── src │ ├── code.c │ └── code.h └── tests └── code_test.c 

To suppress warnings for lib includes, I did this:

cppcheck --enable=all --suppress='*:lib/*' -Isrc -Itests ./src ./tests 1>/dev/null 

Maybe this should work on Windows:

cppcheck.exe --suppress='*:c:\gtest\*' c:\projectfolder\ 

My Cppcheck version is 1.74.

Reference:

Allow ignoring results from header files

1 Comment

Note that this does not prevent the gtest files from being analyzed. Cppcheck still fully analyzes gtest, it just doesn't report errors it finds. Suppressing the errors is a good stopgap, but it would be nice if there was a way to just not analyze some dependencies at all - I just want Cppcheck to look at my 100-line source file and any issues within, say, gtest aren't really my problem. Maybe I'm misunderstanding how Cppcheck is supposed to be used but it takes so long to look at these included libraries that it doesn't seem feasible to be used as part of a standard local build setup.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.