Wemos D1 8266 lite / mini no std::mutex


hopefully I have chosen the right Category. If not feel free to move it :slight_smile: .

I am actually porting some ESP32 code to ESP8266 (D1 Mini). Strangely, I can use std::mutex on the ESP32, but I cannot use it on the 8266.

Installed PIO fresh on a VM (latest version) and wrote a very simple example:


platform = espressif8266
board = d1_mini
framework = arduino


#include <Arduino.h>

#include <mutex>

using std::mutex;

void setup() {}

void loop() {}


src\main.cpp:5:12: error: 'mutex' has not been declared in 'std'
    5 | using std::mutex;
      |            ^~~~~
*** [.pio\build\d1_mini\src\main.cpp.o] Error 1

I know there is also a mutex of FreeRTOS, but i´d like to stick with the std one, which should be available since C++ 11.
Does someone maybe know the reason why it is not available here, and what to do to fix it?

It’s the responsibility of the toolchain creators to provide the mutex. If it doesn’t provide it there’s not much you can do except write wrapper classes / polyfills. Please ask at Arduino-ESP8266: Issues · esp8266/Arduino · GitHub

1 Like

Thank you, have opened an issue: