Page 1 of 1

regex + rtti

Posted: Mon Sep 27, 2021 8:41 am
by dontpostalot
I get linker errors when I try to use regexes with rtti enabled (by adding "build_unflags = -fno-rtti" to platformio.ini). It does link without rtti.

Here's the sketch:

Code: Select all

#include <Arduino.h>
#include <regex>

void setup() {
  Serial.begin(115200, SERIAL_8N1);
}

void loop() {
      std::regex reg("man");
    if (std::regex_search("Here is my man.", reg))
        Serial.println("Matched");
    else
        Serial.println("Not matched");

  delay(1000);
}
And the errors:

.pio\build\esp32dev\src\main.cpp.o:(.literal._ZNSt8__detail8_ScannerIcEC5EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale[std::__detail::_Scanner<char>::_Scanner(char const*, char const*, std::regex_constants::syntax_option_type, std::locale)]+0x1c): undefined reference to `typeinfo for std::ctype<char>'
.pio\build\esp32dev\src\main.cpp.o:(.literal._ZNSt8__detail8_ScannerIcEC5EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale[std::__detail::_Scanner<char>::_Scanner(char const*, char const*, std::regex_constants::syntax_option_type, std::locale)]+0x20): undefined reference to `typeinfo for std::locale::facet'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp32dev\firmware.elf] Error 1

Any ideas?