How can I tell Cppcheck to skip a header file

Johannes picture Johannes · Nov 27, 2012 · Viewed 7.8k times · Source

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?

Answer

Daniel Marjamäki picture Daniel Marjamäki · Nov 28, 2012

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

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