I use cppcheck on a project using the boost library. The headers in this library contain a huge amount of macro that I don't even use in my sources. Nevertheless, cppcheck explore paths depending on these macros that I think useless. Is there a way to tell cppcheck to ignore all macros unless it's defined in a source code using a #define?
Here is the the necessary part from cppcheck documentation:
-D<ID> Define preprocessor symbol. Unless --max-configs or
--force is used, Cppcheck will only check the given
configuration when -D is used.
Example: '-DDEBUG=1 -D__cplusplus'.
-U<ID> Undefine preprocessor symbol. Use -U to explicitly
hide certain #ifdef <ID> code paths from checking.
Example: '-UDEBUG'
You are able to define (-D) or undefine (-U) custom preprocesser symbols with these options.
Another option that is potentially interesting is
-f, --force Force checking of all configurations in files. If used
together with '--max-configs=', the last option is the
one that is effective.
and
--max-configs=<limit>
Maximum number of configurations to check in a file
before skipping it. Default is '12'. If used together
with '--force', the last option is the one that is
effective.
This means the following:
cppcheck --force <PATH_TO_YOUR_CODE>
Cppcheck verifies all combinations of preprocessor paths, which could lead to long checking times on large code bases.
The corresponding documentation can be found here.
Not exactly what you want, but you can specify define
to cppcheck so it evaluates only one branch:
see -D
/-U
options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With