Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArduinoJson.h error: if (_destination->concat(_buffer)) #1812

Closed
gck303 opened this issue Oct 11, 2022 · 3 comments · May be fixed by PaulStoffregen/cores#662
Closed

ArduinoJson.h error: if (_destination->concat(_buffer)) #1812

gck303 opened this issue Oct 11, 2022 · 3 comments · May be fixed by PaulStoffregen/cores#662

Comments

@gck303
Copy link

gck303 commented Oct 11, 2022

Description
I would expect the code to complile!

Troubleshooter's report

  1. The issue happens at compile time
  2. The error is not in the list

Environment

  • Microcontroller: Teensy 4.1
  • Core/Framework: Teensyduino 1.57
  • IDE: 1.8.19

Reproduction code

#include <ArduinoJson.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Remarks
I cannot get the ArduinoJson.h include to compile correctly. I get these errors:

In file included from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Serialization/Writer.hpp:38:0,
from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Serialization/serialize.hpp:7,
from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Json/JsonSerializer.hpp:10,
from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:7,
from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson.hpp:37,
from C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson.h:9,
from C:\Users\gck.CAMLEY\Documents\Arduino\sketch_oct11b\sketch_oct11b.ino:1:
C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp: In member function 'size_t ArduinoJson6194_1::Writer<String, void>::flush()':
C:\Users\gck.CAMLEY\Documents\libraries\ArduinoJson\src/ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp:42:29: error: could not convert '((ArduinoJson6194_1::Writer<String, void>)this)->ArduinoJson6194_1::Writer<String, void>::_destination->String::concat(((const char)((char*)(&((ArduinoJson6194_1::Writer<String, void>*)this)->ArduinoJson6194_1::Writer<String, void>::_buffer))))' from 'String' to 'bool'
if (_destination->concat(_buffer))
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
Error compiling for board Teensy++ 2.0.

@bblanchon
Copy link
Owner

bblanchon commented Oct 11, 2022

Hi @gck303,

Unfortunately, Teensy's core doesn't implement Arduino's String class correctly.
See PaulStoffregen/cores#561

It works on recent Teensy versions because they added a conversion from String to bool, but this change was never backported to Teensy 2.
Given the silent reaction I received, I didn't try to open a PR.

As a workaround, you can disable the support for Arduino's String class by defining ARDUINOJSON_ENABLE_ARDUINO_STRING to 0.

Best regards,
Benoit

@gck303
Copy link
Author

gck303 commented Oct 11, 2022

Wow. Thank you.

I cannot image how long I would have taken to find this.

I have added the line "#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0" and it compiles now.

@gck303 gck303 closed this as completed Oct 11, 2022
bblanchon added a commit to bblanchon/teensy that referenced this issue Oct 12, 2022
@bblanchon
Copy link
Owner

I opened a PR 🤞

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants