In the header file, NEV_LOGD is defined as follows
'#define NEV_LOGD(...) {(void)0;}
In the cpp file, the target source file is like below:
'#include <header.hpp>
int main() {
int test = 0;
NEV_LOGD(DEBUG, "main start %u", test);
}</header.hpp>
Although NEV_LOGD is declared like this in the header file,
NEV_LOGD(...) {(void)0;}
I want to check for format errors in NEV_LOGD,
but even with the following declaration in the library xml, no error occurs:
<function name="NEV_LOGD">
<formatstr type="printf">
<arg nr="1">
<formatstr>
</formatstr></arg>
</formatstr></function>
If I remove the definition of NEV_LOGD from the header file, the check works.
Is there any way to ensure that the file format declared in the library is always checked?
Last edit: yoosang.won 2025-02-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the header file, NEV_LOGD is defined as follows
'#define NEV_LOGD(...) {(void)0;}
In the cpp file, the target source file is like below:
'#include <header.hpp>
int main() {
int test = 0;
NEV_LOGD(DEBUG, "main start %u", test);
}</header.hpp>
Although NEV_LOGD is declared like this in the header file,
NEV_LOGD(...) {(void)0;}
I want to check for format errors in NEV_LOGD,
but even with the following declaration in the library xml, no error occurs:
<function name="NEV_LOGD">
<formatstr type="printf">
<arg nr="1">
<formatstr>
</formatstr></arg>
</formatstr></function>
If I remove the definition of NEV_LOGD from the header file, the check works.
Is there any way to ensure that the file format declared in the library is always checked?
Last edit: yoosang.won 2025-02-05
If you wrap the definition this this:
cppcheck will consider the case where your define does not happen.
You will need to use
cppcheck --enable=style source.cpp
to get the warning