Skip to content

Both 3x and 4 fail to compile jsonlib.cpp in Arduino 1.8.1.3 and 2.0.0-beta.5 #125

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

Closed
hylioja opened this issue Jun 9, 2021 · 4 comments · Fixed by #130
Closed

Both 3x and 4 fail to compile jsonlib.cpp in Arduino 1.8.1.3 and 2.0.0-beta.5 #125

hylioja opened this issue Jun 9, 2021 · 4 comments · Fixed by #130
Labels
bug Something isn't working question Further information is requested

Comments

@hylioja
Copy link

hylioja commented Jun 9, 2021

Both versions (3.x and 4) fail with this error message in both Arduino 1.8.1.3 and 2.0.0-beta.5:

sketch\src\jsonlib\jsonlib.cpp: In function 'String jsonExtract(String, String)':
sketch\src\jsonlib\jsonlib.cpp:75:34 error: 'std:string' has not been declared
if (json.indexOf(name) == std::string:npos) return json.substring(0,0);

@easytarget easytarget added the question Further information is requested label Jun 14, 2021
@easytarget
Copy link
Owner

That looks like a really fundamental corruption in your ESP arduino core install. The std:string stuff is included via Arduino.h and a core part of all arduino toolchains.

There is nothing to 'fix' in my code for this, you need fix whatever is wrong in your toolchain.

@blurfl
Copy link

blurfl commented Jun 30, 2021

I too am seeing this issue when using the alpha preview version of the ESP arduino core. Dropping back to the 1.06 release compiles correctly. I find that the simple strings test example compiles correctly with the alpha (maybe because it does not call std::string::npos ?) At any rate the issue with std::string::npos seems to lie with the alpha version of the core.

For now, to keep working with the alpha I work around the issue by editing src/jsonlib.cpp line 76 to avoid the issue:

  if (json.indexOf(name) == name.length()) return json.substring(0,0);

@easytarget
Copy link
Owner

easytarget commented Jun 30, 2021

https://www.cplusplus.com/reference/string/string/npos/
It's a constant that represents 'No Position'

So the conditional (json.indexOf(name) == std::string:npos) is basically testing to see if name exists in the input, I'm not convinced your modified line will work reliably.

Looks like this needs to be taken up as a issue with the ESP alpha.

@easytarget
Copy link
Owner

easytarget commented Jun 30, 2021

I just submitted espressif/arduino-esp32#5342

However, I'm pretty sure this is now the intended behaviour for the ESP core, it makes it consistent with other cores, eg neither the esp8266 or the official Arduino cores support std::string in this way either. String support in Arduino-land is, by convention, a subset of the full std::string package.

So I've done a proper fix in the code to remove the std::string reference and ensure this is not a problem going forward.

@easytarget easytarget linked a pull request Jun 30, 2021 that will close this issue
@easytarget easytarget added the bug Something isn't working label Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants