Skip to content

std::string no longer available for 2.x (regression from 1.x) #5342

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
easytarget opened this issue Jun 30, 2021 · 2 comments
Closed

std::string no longer available for 2.x (regression from 1.x) #5342

easytarget opened this issue Jun 30, 2021 · 2 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@easytarget
Copy link

easytarget commented Jun 30, 2021

In the IDE 1.0.6 the following code will compile and run properly

#include "Arduino.h"

String someText = "This is my example";

void setup() {
    Serial.begin(115200);
    Serial.println("Started");
}

void loop() {
    String match = "NO";
    // put your main code here, to run repeatedly:
    if (someText.indexOf(match) == std::string::npos) {
        Serial.println("No match");
    } else { 
        Serial.println("Match");
    }
    delay(1000);
}

However, with 2.0.0-alpha1 compilation fails with:

/home/owen/Arduino/std.string.npos.reproduction/std.string.npos.reproduction.ino: In function 'void loop()':
std.string.npos.reproduction:14:41: error: 'std::string' has not been declared
     if (someText.indexOf(match) == std::string::npos) {
                                         ^~~~~~
exit status 1
'std::string' has not been declared

So; starting from 2.0.0 the esp32 toolchain no longer supports the std::string class. This is actually in line with other boards; for instance the esp8266 and offiicial Arduino boards fail to compile this code giving the same error.

However, while this brings the ESP32 code into line with other Arduino toolchains, it will break some legacy projects that have taken advantage of std::string being present.

I'm submitting this issue not because I think this needs 'fixing' (I'll modify my code) but because I forsee quite a few older esp32 projects that will be broken by this, and having a placeholder for the issues will be useful. I could not see any existing discussion of this here or elsewhere.

@easytarget easytarget changed the title std::stringno longer available for 2.x (regression from 1.x) std::string no longer available for 2.x (regression from 1.x) Jul 1, 2021
@stale
Copy link

stale bot commented Sep 3, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 3, 2021
@stale
Copy link

stale bot commented Sep 19, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

1 participant