Search code examples
qt-creatorstatic-analysiscppcheck

CppCheck claims that a field is not used - while it is, in another file


I created a custom type, and put it into command.h

typedef struct 
{
    char name[16];
    int paramv[7];
    int paramc;
} command;

I'm using it in many other files, but not in command.*. Now I ran the CppCheck test with the QtCreator cppcheck plug-in. What I get is:

command.h:12: warning: Cppcheck: struct member 'command::name' is never used.

The same warning happens when I do

 cppcheck src --enable=all --suppress=missingIncludeSystem src/*

What am I doing wrong?


Solution

  • Hello I am a Cppcheck developer.

    You should not check headers directly.

    This warning is only written for non-included files. If you check command.h directly then command.h is not included so the warning is written.

    So remove the src/* in your command. That option will mean that textfiles, images and whatever you have in src are checked.