bblanchon/ArduinoJson

Cannot compile code that compiled last time it was used

tofof opened this issue · 1 comments

Describe the issue
New installation of VScode & platformio. Imported old project. ArduinoJson is erroring up in libdeps and when used in my program.

Sorry, I'm at a loss as to what's happened. As far as I knew, my bblanchon/ArduinoJson@^6.20.0 libdep entry should've locked it to the version I was using and compatible fixes. I found a similar issue but it was the result of lacking the version specifier, which I have.

Troubleshooter report
Here is the report generated by the ArduinoJson Troubleshooter:

  1. The program uses ArduinoJson 6
  2. The issue happens at compile time
  3. Error says "expected identifier before string constant"
  4. Program doesn't target a WisBlock RUI3

Environment
Here is the environment that I'm using':

  • Microconroller: espressif8266 wemos d1 mini
  • Core/runtime: framework-arduinoespressif8266 @ 3.30102.0 (3.1.2)
  • IDE: visual studio code 1.90.0 with platformio 6.1.15

Reproduction

Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini.html
PLATFORM: Espressif 8266 (4.2.1) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 @ 3.30102.0 (3.1.2)
 - tool-esptool @ 1.413.0 (4.13)
 - tool-esptoolpy @ 1.30000.201119 (3.0.0)
 - toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 43 compatible libraries
Scanning dependencies...
Dependency Graph
|-- DHT sensor library for ESPx @ 1.18.0
|-- PubSubClient @ 2.8.0
|-- ArduinoJson @ 6.21.5
|-- TM1637TinyDisplay @ 1.1.0
|-- Omron_D6FPH @ 1.1.0
|-- ESP8266WiFi @ 1.0
|-- Wire @ 1.0
Building in release mode
Compiling .pio\build\d1_mini\src\main.cpp.o
Compiling .pio\build\d1_mini\lib415\ESP8266WiFi\enable_wifi_at_boot_time.cpp.o
Archiving .pio\build\d1_mini\libFrameworkArduinoVariant.a
Compiling .pio\build\d1_mini\FrameworkArduino\Crypto.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\Esp-frag.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\Esp-version.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\FS.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\FSnoop.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\FunctionalInterrupt.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\d1_mini\FrameworkArduino\LwipDhcpServer-NonOS.cpp.o
src\main.cpp: In function 'void sendMQTTDiscoveryMsg(String, String, String, String, String)':
src\main.cpp:56:20: error: expected identifier before string constant
   56 |   device["ids"] = ["ff1"];
      |                    ^~~~~
src\main.cpp: In lambda function:
src\main.cpp:56:26: error: expected '{' before ';' token
   56 |   device["ids"] = ["ff1"];
      |                          ^
In file included from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.hpp:42,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:7:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In instantiation of 'static void ArduinoJson::V6215PB2::Converter<T, Enable>::toJson(const T&, ArduinoJson::V6215PB2::JsonVariant) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; Enable = void]':
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/VariantImpl.hpp:140:57:   required from 'bool ArduinoJson::V6215PB2::detail::VariantRefBase<TDerived>::set(const T&) const [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TDerived = ArduinoJson::V6215PB2::detail::MemberProxy<ArduinoJson::V6215PB2::JsonObject, const char*>]'
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:33:14:   required from 'ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >& ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(const T&) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TUpstream = ArduinoJson::V6215PB2::JsonObject; TStringRef = const char*]'
src\main.cpp:56:26:   required from here
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:25:18: error: no matching function for call to 'convertToJson(const sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>&, ArduinoJson::V6215PB2::JsonVariant&)'
   25 |     convertToJson(src, dst); // Error here? See https://arduinojson.org/v6/unsupported-set/
      |     ~~~~~~~~~~~~~^~~~~~~~~~
In file included from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Document/BasicJsonDocument.hpp:7,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Document/DynamicJsonDocument.hpp:7,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.hpp:33,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:7:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Document/JsonDocument.hpp:321:13: note: candidate: 'void ArduinoJson::V6215PB2::convertToJson(const ArduinoJson::V6215PB2::JsonDocument&, ArduinoJson::V6215PB2::JsonVariant)'
  321 | inline void convertToJson(const JsonDocument& src, JsonVariant dst) {
      |             ^~~~~~~~~~~~~
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Document/JsonDocument.hpp:321:47: note:   no known conversion for argument 1 from 'const sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>' to 'const ArduinoJson::V6215PB2::JsonDocument&'
  321 | inline void convertToJson(const JsonDocument& src, JsonVariant dst) {
      |                           ~~~~~~~~~~~~~~~~~~~~^~~
In file included from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.hpp:42,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:7:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:256:13: note: candidate: 'void ArduinoJson::V6215PB2::convertToJson(const Printable&, ArduinoJson::V6215PB2::JsonVariant)'
  256 | inline void convertToJson(const ::Printable& src, JsonVariant dst) {
      |             ^~~~~~~~~~~~~
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:256:46: note:   no known conversion for argument 1 from 'const sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>' to 'const Printable&'
  256 | inline void convertToJson(const ::Printable& src, JsonVariant dst) {
      |                           ~~~~~~~~~~~~~~~~~~~^~~
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:164:1: note: candidate: 'template<class T> typename ArduinoJson::V6215PB2::detail::enable_if<ArduinoJson::V6215PB2::detail::IsString<TString>::value, bool>::type ArduinoJson::V6215PB2::convertToJson(const T&, ArduinoJson::V6215PB2::JsonVariant)'
  164 | convertToJson(const T& src, JsonVariant dst) {
      | ^~~~~~~~~~~~~
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:164:1: note:   template argument deduction/substitution failed:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In substitution of 'template<class T> typename ArduinoJson::V6215PB2::detail::enable_if<ArduinoJson::V6215PB2::detail::IsString<TString>::value, bool>::type ArduinoJson::V6215PB2::convertToJson(const T&, ArduinoJson::V6215PB2::JsonVariant) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>]':
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:25:18:   required from 'static void ArduinoJson::V6215PB2::Converter<T, Enable>::toJson(const T&, ArduinoJson::V6215PB2::JsonVariant) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; Enable = void]'
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/VariantImpl.hpp:140:57:   required from 'bool ArduinoJson::V6215PB2::detail::VariantRefBase<TDerived>::set(const T&) const [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TDerived = ArduinoJson::V6215PB2::detail::MemberProxy<ArduinoJson::V6215PB2::JsonObject, const char*>]'
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:33:14:   required from 'ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >& ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(const T&) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TUpstream = ArduinoJson::V6215PB2::JsonObject; TStringRef = const char*]'
src\main.cpp:56:26:   required from here
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:164:1: error: no type named 'type' in 'struct ArduinoJson::V6215PB2::detail::enable_if<false, bool>'
In file included from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.hpp:44,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:7:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In instantiation of 'static void ArduinoJson::V6215PB2::Converter<T, Enable>::toJson(const T&, ArduinoJson::V6215PB2::JsonVariant) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; Enable = void]':
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/VariantImpl.hpp:140:57:   required from 'bool ArduinoJson::V6215PB2::detail::VariantRefBase<TDerived>::set(const T&) const [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TDerived = ArduinoJson::V6215PB2::detail::MemberProxy<ArduinoJson::V6215PB2::JsonObject, const char*>]'
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:33:14:   required from 'ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >& ArduinoJson::V6215PB2::detail::MemberProxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(const T&) [with T = sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>; TUpstream = ArduinoJson::V6215PB2::JsonObject; TStringRef = const char*]'
src\main.cpp:56:26:   required from here
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/VariantImpl.hpp:178:13: note: candidate: 'template<class TDerived> void ArduinoJson::V6215PB2::detail::convertToJson(const ArduinoJson::V6215PB2::detail::VariantRefBase<TDerived>&, ArduinoJson::V6215PB2::JsonVariant)'
  178 | inline void convertToJson(const VariantRefBase<TDerived>& src,
      |             ^~~~~~~~~~~~~
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/VariantImpl.hpp:178:13: note:   template argument deduction/substitution failed:
In file included from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.hpp:42,
                 from .pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson.h:9,
                 from src\main.cpp:7:
.pio\libdeps\d1_mini\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:25:18: note:   'const sendMQTTDiscoveryMsg(String, String, String, String, String)::<lambda()>' is not derived from 'const ArduinoJson::V6215PB2::detail::VariantRefBase<TDerived>'
   25 |     convertToJson(src, dst); // Error here? See https://arduinojson.org/v6/unsupported-set/
      |     ~~~~~~~~~~~~~^~~~~~~~~~
*** [.pio\build\d1_mini\src\main.cpp.o] Error 1
========================================================================================== [FAILED] Took 4.22 seconds ==========================================================================================
 *  The terminal process "C:\Users\Brian\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

My platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps = 
	beegee-tokyo/DHT sensor library for ESPx@^1.18
	knolleary/PubSubClient@^2.8
	bblanchon/ArduinoJson@^6.20.0
	jasonacox/TM1637TinyDisplay@^1.1.0
	bitixel/Omron_D6FPH@^1.1.0
monitor_speed = 115200

Hi @tofof,

device["ids"] = ["ff1"];

This is not valid C++.

If you want ids to be an array, you must write:

device["ids"].add("ff1");

Best regards,
Benoit