typedef struct foobar_s
{
int foo;
int bar;
} foobar_t;
dan@danuc:~/sandbox/cppcheck$ cppcheck --enable=style --language=c unusedStructMember.h
Checking unusedStructMember.h ...
unusedStructMember.h:4:9: style: struct member 'foobar_s::foo' is never used. [unusedStructMember]
int foo;
^
unusedStructMember.h:5:9: style: struct member 'foobar_s::bar' is never used. [unusedStructMember]
int bar;
^
dan@danuc:~/sandbox/cppcheck$ cppcheck --version
Cppcheck 2.7 dev
dan@danuc:~/sandbox/cppcheck$ git -C ~/tools/cppcheck/ describe
1.40-21987-g2998382c8```
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is by intention. If you check a header directly you will get this FP. The handling of ifdefs does not work very well neither when you check the header directly..
check the c/c++ files that include the header instead.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
```
dan@danuc:~/sandbox/cppcheck$ cat unusedStructMember.h
dan@danuc:~/sandbox/cppcheck$ cppcheck --enable=style --language=c unusedStructMember.h
Checking unusedStructMember.h ...
unusedStructMember.h:4:9: style: struct member 'foobar_s::foo' is never used. [unusedStructMember]
int foo;
^
unusedStructMember.h:5:9: style: struct member 'foobar_s::bar' is never used. [unusedStructMember]
int bar;
^
dan@danuc:~/sandbox/cppcheck$ cppcheck --version
Cppcheck 2.7 dev
dan@danuc:~/sandbox/cppcheck$ git -C ~/tools/cppcheck/ describe
1.40-21987-g2998382c8```
This is by intention. If you check a header directly you will get this FP. The handling of ifdefs does not work very well neither when you check the header directly..
check the c/c++ files that include the header instead.
if you really want to check headers directly anyway.. you can do it. but I suggest that you suppress this warning then.
Ah, okay. I'm using cppcheck with vim ale plugin. I've a PR to change how the plugin handles header files: https://github.com/dense-analysis/ale/pull/3983