cppcheck 2.22.0 generates unusedPrivateFunction and unusedFunction for the following code:
#define CASE(msg, handler) \ case msg: CASE_##msg((handler)) #define MSG1 1 #define CASE_MSG1(handler) handler() class Object { private: int m_num; public: Object() : m_num(0) {} static void msg_proc(int msg, void *context) { switch (msg) { CASE(MSG1, reinterpret_cast<Object*>(context)->msg1_handler); } } private: void msg1_handler() { m_num = 1; } }; int main() { Object obj; Object::msg_proc(MSG1, reinterpret_cast<void*>(&obj)); return 0; }
test\main.cpp:20:7: style: Unused private function: 'Object::msg1_handler' [unusedPrivateFunction] void msg1_handler() ^ test\main.cpp:20:7: note: Unused private function: 'Object::msg1_handler' void msg1_handler() ^ test\main.cpp:20:7: note: Unused private function: 'Object::msg1_handler' void msg1_handler() ^ test\main.cpp:20:7: style: The function 'msg1_handler' is never used. [unusedFunction] void msg1_handler() ^
Without parentheses around handler, warnings are not generated:
#define CASE(msg, handler) \ case msg: CASE_##msg(handler)
Added here: https://trac.cppcheck.net/ticket/15058
Log in to post a comment.
cppcheck 2.22.0 generates unusedPrivateFunction and unusedFunction for the following code:
Without parentheses around handler, warnings are not generated:
Added here: https://trac.cppcheck.net/ticket/15058