启用浮点数格式化支持
Keil MDK-ARM
- 打开工程选项 → Target → Code Generation 勾选 Use MicroLIB。
- 在 Linker 选项卡 → Misc Controls 添加
--u _printf_float。
vscode + platformIO
PlatformIO 默认使用的 newlib-nano 库禁用了浮点数格式化(以节省空间),需手动启用。在项目根目录的 platformio.ini 中添加以下配置:
; 添加以下编译选项
build_flags =
-Wl,-u,_printf_float ; 启用 printf 浮点支持




