I have a number of functions that contain inline assembler and cppcheck is (quite reasonably) showing errors in this code. Is there a way to tell cppcheck to ignore a specific function in it's checks? I can suppress individual errors, but then they would change as the code is updated.
// cppcheck-suppress ignoreThisFunction?
void test_func() {
__asm
; enter hl = void *src // style:Variable 'hl' is assigned a value that is never used
out (c),h // warning:Found suspicious operator ','
__endasm;
}
The way I deal with tools like cppcheck or lint not properly understanding certain constructs is that I call them with a macro definition identifying the tool, and then using conditional compilation. This way I can hide arbitrary code or write something equivalent in proper C.
E.g. you run cppcheck -DCPPCHECK=1 ...
in conjunction with
void test_func(void) {
#if CPPCHECK
/* Hide asm from cppcheck. Somewhat mimick the asm semantics. */
hl = *src; /* Or just leave it empty if that is not possible. */
#else
__asm
; enter hl = void *src
out (c),h
__endasm;
#endif
}