First, thank you for developing and maintaining this great open-source tool!
I maybe missed that in the documentation but is there a way to analyse the code with and without some specific preprocessor symbols?
I know that I can use -D and -U and if I don't use any, cppcheck will try different configurations.
I can still force cppcheck to look at different configurations by using --force or --max-configs options. But if I include some headers from /usr/include, I don't want to use these options as it will look at "generic" preprocessor symbols. Is there a way to select these preprocessor symbols?
I would like to always use the path where B is defined (-DB) but still analyse the code when A is defined and not defined, e.g. not to report that y() and z() and not used. Is it possible to do that with one command? Or do I have to add ifdef around y() and z() functions and run cppcheck twice on all my project, once with -DB -DA and the other time with -DB -UA?
Note that I quickly tried with -DA and -UA at the same time but then I think I had a situation where A is defined and not defined at the same time! Leading in this example at the situation where x is not defined at all. I quickly tried that with cppcheck 1.67 (on Debian Jessie).
Thanks!
Matt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
First, thank you for developing and maintaining this great open-source tool!
I maybe missed that in the documentation but is there a way to analyse the code with and without some specific preprocessor symbols?
I know that I can use
-D
and-U
and if I don't use any, cppcheck will try different configurations.I can still force cppcheck to look at different configurations by using
--force
or--max-configs
options. But if I include some headers from/usr/include
, I don't want to use these options as it will look at "generic" preprocessor symbols. Is there a way to select these preprocessor symbols?Here is an example:
I would like to always use the path where
B
is defined (-DB
) but still analyse the code whenA
is defined and not defined, e.g. not to report thaty()
andz()
and not used. Is it possible to do that with one command? Or do I have to addifdef
aroundy()
andz()
functions and run cppcheck twice on all my project, once with-DB -DA
and the other time with-DB -UA
?Note that I quickly tried with
-DA
and-UA
at the same time but then I think I had a situation whereA
is defined and not defined at the same time! Leading in this example at the situation wherex
is not defined at all. I quickly tried that with cppcheck 1.67 (on Debian Jessie).Thanks!
Matt
hmm that code is not handled well by Cppcheck we'll need to look at that.
I created one ticket to improve Preprocessor::getConfigs():
http://trac.cppcheck.net/ticket/8092
Hi Daniel,
Thank you for your reply (sorry for the delay, I didn't get any notification).
Thank you for the ticket!
Cheers,
Matt