regex + rtti

dontpostalot
Posts: 5
Joined: Wed Sep 15, 2021 12:51 pm

regex + rtti

Postby dontpostalot » Mon Sep 27, 2021 8:41 am

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?

Who is online

Users browsing this forum: atm_turbo, Baidu [Spider] and 91 guests