arm-none-eabi-gcc :使用 printf 打印浮点数 [英] arm-none-eabi-gcc : Printing float number using printf

查看:91
本文介绍了arm-none-eabi-gcc :使用 printf 打印浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 SAM3N arm cortex-M3 微控制器编写 C 程序.当我尝试打印浮点数时,它只打印f".示例:printf("%f",43.12); 仅打印 f,而不是 43.12.

I am writing a C program for SAM3N arm cortex-M3 microcontroller. When I try to print float numbers, it just prints 'f'. Example: printf("%f",43.12); prints f only, not the 43.12.

但是用整数打印效果很好.

But printing with integers works fine.

如何启用浮点数的完整打印?我知道编译器默认禁用浮点打印以减少代码大小(即似乎他们链接了缩减版本).另外请注意,makefile中没有使用CFLAGS=-Dprintf=iprintf.

How to enable full printing of floats? I know that the compiler, by default, disabled float printing to reduce code size (i.e. seems, they linked cut-down version). Also please note that, there is no CFLAGS=-Dprintf=iprintf used in makefile.

工具详情:

  • ARM/GNU C 编译器:(crosstool-NG 1.13.1 - Atmel 版本:13)4.6.1
  • 以上工具随 Atmel Studio 6.0 提供.

推荐答案

你可以试试,在链接器设置中添加以下选项

Can you try, adding the below option in linker settings

-lc -lrdimon -u _printf_float

-lc -lrdimon -u _printf_float

它在 ARM-CORTEXM0 中对我有用

and it worked for me in ARM-CORTEXM0

这篇关于arm-none-eabi-gcc :使用 printf 打印浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆