如何修复 mbed 错误: 'wait' was not declared in this scope (PlatformIO)

问题:

编译你的 mbed / PlatformIO 应用程序时,你看到类似这样的错误消息

output.txt
src/actuators.cpp:253:5: error: 'wait' was not declared in this scope
    253 |     wait(1.0);
            |     ^~~~

解决方案

wait 是旧 API,已被弃用,推荐使用 C++ 标准 ThisThread::sleep_for。使用

example.cpp
ThisThread::sleep_for(1s);

Check out similar posts by category: Embedded, Mbed, PlatformIO