Cppcheck: how to skip a directory of third party header files?

Another possibility would be to use suppressions via a file (see manual chapter 7 “Listing suppressions in a file”) or via commandline. Your suppressions.txt could be *:/path/to/your/thirdpartylibs/* Which would exclude all errors from that path. The syntax is [error id]:[filename]:[line] with wildcard support for * (multiple characters) and ? (single character). The call to cppcheck … Read more

Rulesets for cppcheck

You won’t be able to implement all MISRA/JSF rules and directives as cppcheck rules, mostly only the straightforward ones restricting certain C language features and constructions or that are style-related (some that come to mind: spaces before/after ./->, # of arguments on a single line, use of unions to provide different methods of accessing memory, … Read more

How to use cppcheck’s inline suppression filter option for C++ code?

You can change the output template to display the error id from the command line, which is quite neat. For a Visual Studio format output with error id displayed, add this to your command line: –template “{file}({line}): {severity} ({id}): {message}” This will produce output something like this: s:\src\jpeg.cpp(123): error (bufferAccessOutOfBounds): Buffer access out-of-bounds: abRY Which … Read more

c++, usleep() is obsolete, workarounds for Windows/MingW?

I used this code from (originally from here): #include <windows.h> void usleep(__int64 usec) { HANDLE timer; LARGE_INTEGER ft; ft.QuadPart = -(10*usec); // Convert to 100 nanosecond interval, negative value indicates relative time timer = CreateWaitableTimer(NULL, TRUE, NULL); SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); WaitForSingleObject(timer, INFINITE); CloseHandle(timer); } Note that SetWaitableTimer() uses “100 nanosecond intervals … … Read more