0

CppCheck is flagging the definition of BufLen as an unusedStructMember, even though it is used on the next line to define the length of the array.

(style) struct member 'TxDetails_t::BufLen' is never used. [unusedStructMember]

static struct TxDetails_t
{
    static constexpr int32_t BufLen = 128;  
    
    uint8_t buffer[BufLen];
    uint8_t* ptr;
    int32_t num_bytes;
    
} TxData;

Is CppCheck wrong to report this, or is there a better way for me to define this struct?

JonathanN
  • 233
  • 2
  • 5

1 Answers1

1

This is indeed a false positive and it is fixed in the upcoming Cppcheck 2.7. I can reproduce it with 2.6 but not with the latest head.

Looking at the list of fixed issues it appears you encountered https://trac.cppcheck.net/ticket/10485.

Firewave
  • 336
  • 2
  • 11