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

#include "Arduino.h" is leaked everywhere that includes "ArduinoJson.h", even if all Arduino features are disabled #1692

Closed
paulocsanz opened this issue Dec 23, 2021 · 2 comments

Comments

@paulocsanz
Copy link
Contributor

paulocsanz commented Dec 23, 2021

Is your feature request related to a problem? Please describe.

We have a lower level layer that implements drivers for each device we support, esp8266/Arduino is one of these backends. When using this backend ARDUINO is always defined to the used version, but we do not use any Arduino types with ArduinoJson (we only use std::string_view).

The problem is that the higher level layer uses ArduinoJson and gets a #include "Arduino.h" with it. Causing conflicts in our platform agnostic code.

We use PlatformIO so we are kinda stuck with its ways of compiling dependencies, we don't want to fork the pio library, and it seems impractical to use this git as the source of truth while compiling the lib separately, zeroing ARDUINO, to then statically link it together with our code. But we are open to ideas.

Describe the solution you'd like

We hope for a simple way to remove the #include "Arduino.h" from src/ArduinoJson/Configuration.hpp#L119 without having to disable all Arduino features from the system.

Maybe if all of the three Arduino features are disabled it could automatically avoid the include. Or we could add an extra define, like ARDUINOJSON_DISABLE_ARDUINO (not necessarily the best name). Also I had a bit of a hard time finding where the include happened and the features that could be disabled. I wasn't able to find in a public doc, is there a link I'm missing?

I am willing to provide a PR.

Just a note, to disable all #include "Arduino.h" leaked from ArduinoJson: ARDUINOJSON_ENABLE_PROGMEM also needs to be set to 0. As src/ArduinoJson/Strings/Adapters/FlashString.hpp includes Arduino.h

@paulocsanz paulocsanz changed the title "Arduino.h" is leaked everywhere that includes "ArduinoJson.h", even if all Arduino features are disabled #include "Arduino.h" is leaked everywhere that includes "ArduinoJson.h", even if all Arduino features are disabled Dec 23, 2021
@bblanchon
Copy link
Owner

Hi @paulocsanz,

Thank you for reporting this issue; I didn't realize people could have ARDUINO defined without actually using any Arduino.h's features.

For the record, this #include was added to address #1070 and #1071, where the user complained about the opposite issue.

I'll look at your PR in a moment.

Best regards,
Benoit

@bblanchon
Copy link
Owner

The fix was release in ArduinoJson 6.19.0.

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

Successfully merging a pull request may close this issue.

2 participants