inso
March 7, 2023, 8:35pm
1
Hi,
hopefully I have chosen the right Category. If not feel free to move it .
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:
platformio.ini:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
main.cpp:
#include <Arduino.h>
#include <mutex>
using std::mutex;
void setup() {}
void loop() {}
Output:
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
inso
March 7, 2023, 9:31pm
3
Thank you, have opened an issue:
opened 09:30PM - 07 Mar 23 UTC
### Basic Infos
- [X] This issue complies with the [issue POLICY doc](https:/… /github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.
#### Platform
- Hardware: ESP-12F
- Core Version: PIO Core 6.1.6
- Development Env: PlatformIO
- Operating System: Windows
### Settings in IDE
- Module: WeMos D1 R2 and mini /
- Flash Mode: dio
- Flash Size: 4MB
- lwip Variant: v1.4
- Reset Method: ck
- Flash Frequency: [40Mhz]
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
### Problem Description
std::mutex is not available. Have set up a Win10 VM and fresh installed VS Code and PIO to ensure it is not related to one of my libraries or such. Still persists.
### [MCVE](https://stackoverflow.com/help/mcve) Sketch
main.cpp:
```
#include <Arduino.h>
#include <mutex>
using std::mutex;
void setup() {}
void loop() {}
```
platformio.ini:
```
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
```
### Output
```
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
```