Hi, I found a preprocessor error in working code that stops cppcheck to continue analysis:
#define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro) #define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro) #define _XXXX1 _YYYY, #define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args 1, 0) #define Z_IS_ENABLED3(ignore_this, val, ...) val #define FOO 1 int main() { return IS_ENABLED(FOO); }
Cppcheck says:
test.cpp:3:0: error: failed to expand 'IS_ENABLED', Wrong number of parameters for macro 'Z_IS_ENABLED2'. [preprocessorErrorDirective] #define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro) ^
but the code is compilable and works fine. If FOO is defined to 0, it is fine for cppcheck. If FOO is undefined, it is fine for cppcheck.
The IS_ENABLED define is not mine, it is from Zephyr code: https://docs.zephyrproject.org/apidoc/latest/util__macro_8h_source.html https://docs.zephyrproject.org/apidoc/latest/util__internal_8h_source.html I extracted it for minimal code.
Thanks, Cristian
Thanks for reporting this. I created this issue: https://github.com/danmar/simplecpp/issues/295
this is solved in the latest git head of the simplecpp library. It should work properly in coming releases simplecpp 1.2.x / cppcheck 2.17
Log in to post a comment.
Hi,
I found a preprocessor error in working code that stops cppcheck to continue analysis:
Cppcheck says:
but the code is compilable and works fine.
If FOO is defined to 0, it is fine for cppcheck.
If FOO is undefined, it is fine for cppcheck.
The IS_ENABLED define is not mine, it is from Zephyr code:
https://docs.zephyrproject.org/apidoc/latest/util__macro_8h_source.html
https://docs.zephyrproject.org/apidoc/latest/util__internal_8h_source.html
I extracted it for minimal code.
Thanks,
Cristian
Thanks for reporting this. I created this issue: https://github.com/danmar/simplecpp/issues/295
this is solved in the latest git head of the simplecpp library. It should work properly in coming releases simplecpp 1.2.x / cppcheck 2.17