bblanchon / ArduinoJson

📟 JSON library for Arduino and embedded C++. Simple and efficient.
https://arduinojson.org
MIT License
6.69k stars 1.12k forks source link

cppcheck: failed to expand 'ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE' #2120

Open robsonos opened 3 weeks ago

robsonos commented 3 weeks ago

Hi,

Just reporting this issue while running cppcheck:

...ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp:7: [high:error] failed to expand 'ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE', Invalid ## usage when expanding 'ARDUINOJSON_CONCAT_': Unexpected token ')' [preprocessorErrorDirective]

Cheers

marco86to commented 3 weeks ago

Hi, I have found the same bug. Cheers

bblanchon commented 3 weeks ago

Hi @robsonos and @marco86to,

Here is line 7 of Polyfills/preprocessor.hpp:

#define ARDUINOJSON_CONCAT_(A, B) A##B

There is no error here!

Also, I ran cppcheck 2.10 on this file and got no error.

Best regards, Benoit

robsonos commented 3 weeks ago

Hi @bblanchon,

For more context, I am using platformio/tool-cppcheck from PlatformIO. I did some testing and coundn't find any issues with the macro expansions of ARDUINOJSON_VERSION_NAMESPACE and ARDUINOJSON_CONCAT_. I wonder if the issue is related to cppcheck itself like in https://community.platformio.org/t/wrong-issues-from-cppcheck/18410/7. In terms of PlatformIO itself, the following will suppress the error:

check_flags =
    cppcheck: --suppress=*:*.pio\*