ArduinoJson icon indicating copy to clipboard operation
ArduinoJson copied to clipboard

cppcheck: failed to expand 'ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE'

Open robsonos opened this issue 1 year ago • 3 comments

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

robsonos avatar Aug 16 '24 06:08 robsonos

Hi, I have found the same bug. Cheers

marco86to avatar Aug 18 '24 12:08 marco86to

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

bblanchon avatar Aug 21 '24 14:08 bblanchon

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\* 

robsonos avatar Aug 22 '24 01:08 robsonos