原提问链接: https://stackoverflow.com/questions/67276661/cppcheck-stop-checking-unusedstructmember
**cppcheck version**:2.3
1.Scan the following code (rsvd.c)
```
typedef struct {
int a;
// cppcheck-suppress unusedStructMember
int b;
int c;
} test;
int main()
{
test A;
A.a = 5;
return 0;
}
```
run `cppcheck --inline-suppr --enable=all rsvd.c`
The results are as follows(as expected):
> Checking rsvd.c ...
>
> rsvd.c:7:9: style: struct member 'test::c' is never used. [unusedStructMember]
>
> int c;
>
> rsvd.c:14:9: style: Variable 'A.a' is assigned a value that is never used. [unreadVariable]
>
> A.a = 5;
2.Scan the following code
```
typedef struct {
int a;
int b;
int c;
} test;
int main()
{
test A = {1, 2, 3};
return 0;
}
```
The results are as follows(not expected):
> Checking rsvd.c ...
>
> rsvd.c:3:9: style: struct member 'test::a' is never used. [unusedStructMember]
>
> int a;
>
> rsvd.c:4:9: style: struct member 'test::b' is never used. [unusedStructMember]
>
> int b;
>
> rsvd.c:5:9: style: struct member 'test::c' is never used. [unusedStructMember]
>
> int c;
>
> rsvd.c:11:12: style: Variable 'A' is assigned a value that is never used. [unreadVariable]
>
> test A = {1, 2, 3};
In the preceding code, a value has been assigned to the structure member variable. This is a false positive of the tool. How can I solve this problem? Thank you very much.