bblanchon / ArduinoJson

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

Error during PlatformIO build for Portenta H7 #1719

Closed mrccwolf closed 2 years ago

mrccwolf commented 2 years ago

Environment

Here is the error, it happens during import.

In file included from .pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8:0,
                 from .pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
                 from .pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson.hpp:17,
                 from .pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:12:
.pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp: In instantiation of 'ArduinoJson6185_91::VariantRef::operator T() const [with T = char*]':
.pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:85:30:   required from 'ArduinoJson6185_91::MemberProxy<TParent, TStringRef>::operator T() const [with T = char*; TObject = ArduinoJson6185_91::JsonDocument&; TStringRef = const char*]'
src\main.cpp:994:26:   required from here
.pio\libdeps\portenta_h7_m7\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:150:17: error: invalid conversion from 'ArduinoJson6185_91::enable_if<true, const char*>::type {aka const char*}' to 'char*' [-fpermissive]
     return as<T>();
            ~~~~~^~
*** [.pio\build\portenta_h7_m7\src\main.cpp.o] Error 1

Can anyone replicate?

mrccwolf commented 2 years ago

This is resolved, this was difficult to find since both IDE were not referencing the correct line number.

incorrect code:

char* type = doc["type"];

corrected

const char* type = doc["type"];