简体   繁体   English

为什么CppCheck flag static constexpr members as usedStructMember,后面在struct定义中使用的时候

[英]Why does CppCheck flag static constexpr members as unusedStructMember, when it is used later in the struct definition

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. CppCheck 将 BufLen 的定义标记为未使用的StructMember,即使它在下一行用于定义数组的长度。

(style) struct member 'TxDetails_t::BufLen' is never used. (样式)结构成员 'TxDetails_t::BufLen' 从未使用过。 [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? CppCheck 是否错误地报告了这一点,或者我是否有更好的方法来定义这个结构?

This is fixed in the upcoming Cppcheck 2.7.这在即将发布的 Cppcheck 2.7 中得到修复。 I can reproduce it with 2.6 but not with the latest head.我可以用 2.6 重现它,但不能用最新的 head。

Looking at the list of fixed issues it appears you encountered https://trac.cppcheck.net/ticket/10485 .查看已修复问题列表,您似乎遇到了https://trac.cppcheck.net/ticket/10485

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM