Teaching cppcheck about all of our header locations drops the number off errors found from 7K to a few hundred. However it also creats 2 new problems: speed and ~10K "toomanyconfigs" warnings.
An example of 2 configurations defined by A is this:
x = y;
x = z;
By default cppcheck will check all preprocessor configurations (except those that have #error in them). So the above code will be analyzed both when A is defined and when it is not
We can speed things up by not checking our DEBUG configurations. We can also eliminate even more false positives by not checking configurations that are missing the system header files. For example on Linux, we should add -U_WIN32 to not check Windows configs.
Here is the result of my tweaking:
$ cppcheck -U_WIN32 -i external/ -i workdir/ --includes-file=inc.txt --xml --suppressions-list=cppcheck_supp.txt --enable=all --max-configs=100 ./ 2> ./err.xml
This command is not perfect, but it greatly improved the signal-to-noise ratio, only showing a few hundred errors. The run time went from about 1 hour to 8, but I'm sure that can be by further by reducing the number of configurations checked (-D and -U).