如何修复 PlatformIO mbed 错误: 'Mutex' does not name a type

问题:

你正在尝试使用类似这样的互斥锁编译你的 PlatformIO mbed 应用程序

mutex-example.c
Mutex myLock;

但你看到类似这样的错误消息

mutex-error.txt
src\main.cpp:3:1: error: 'Mutex' does not name a type
 Mutex myLock;
 ^~~~~

解决方案

将此行添加到你的 platformio.ini

platformio.ini.snippet
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

这将启用 mbed 中的 RTOS 功能,包括 Mutex


Check out similar posts by category: Mbed, PlatformIO