Then in which cases does Cppcheck guess value of the macros. Because, while creating dumps, sometimes there were multiple configurations and other times only 1. I don't have access to older codes (because i deleted them) so I cannot reproduce the same behavior. In other terms, how does Cppcheck create configurations (with regards to macros) while creating dumps?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this guess happens before parsing so it is difficult to see how the macro is used. it is just seen in the code and then you get the warning.
We can guess configurations for most code automatically but this is a case where proper analysis requires proper macro values. Have you tried to use the --project flag? I would suggest that flag.
Even if Cppcheck determines that it's a function name it's very hard to guess the proper macro value. It could be anything. For instance it could be a=a or a=Foo::bar... we can't know what the proper name is.
Last edit: Daniel Marjamäki 2021-01-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cppcheck throws [ConfigurationNotChecked] error with or without --force flag. I have a simple header:
Cppcheck skips both configs.
yes this is a case where we want to have explicit configuration with
-D
. I do not want to guess a concrete value of a macro that is used in the code.Then in which cases does Cppcheck guess value of the macros. Because, while creating dumps, sometimes there were multiple configurations and other times only 1. I don't have access to older codes (because i deleted them) so I cannot reproduce the same behavior. In other terms, how does Cppcheck create configurations (with regards to macros) while creating dumps?
when the macros are only used in preprocessor directives we can safely guess..:
if cppcheck guess
a=1
ora=1000
doesn't matter.put a or b somewhere in the code and it's not safe to guess anymore..
If we guess a=1 and that is never the real value then the analysis might be wrong and there could be false positives.
Last edit: Daniel Marjamäki 2021-01-19
well if both a=1 and a=1000 means that the condition is true then it does not matter.
I see. I guess same goes for when function name and macro is the same. Why is that though?
this guess happens before parsing so it is difficult to see how the macro is used. it is just seen in the code and then you get the warning.
We can guess configurations for most code automatically but this is a case where proper analysis requires proper macro values. Have you tried to use the
--project
flag? I would suggest that flag.Even if Cppcheck determines that it's a function name it's very hard to guess the proper macro value. It could be anything. For instance it could be a=a or a=Foo::bar... we can't know what the proper name is.
Last edit: Daniel Marjamäki 2021-01-20