当我创建一个新项目并在链接器选项中添加 "-u _printf_float",并选择“使用 newlib-nano 的 printf 浮点支持 (-u _printf_float)”时,sprintf 仍然无法转换浮点值。
但当我导入一个 TrueStudio 项目(其中 sprintf 可以正常处理浮点数)时,在 CubeIDE 中也能正常工作。操作上,哪里有问题?
编译器设置:
mcpu=cortex-m4 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DSTM32F446xx -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Include -I../Drivers/STM32F4xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
连接设置
-mcpu=cortex-m4 -T"D:\HiDrive\STM32\workspace_1.0.0\printf\STM32F446RETX_FLASH.ld" --specs=nosys.specs -Wl,-Map="${ProjName}.map" -Wl,--gc-sections -static -u _printf_float --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group
|
|