为什么float类型在Keil上能很好地工作而在Eclipse(gcc)上却不能 [英] Why does float types works well with Keil but not with Eclipse (gcc)
问题描述
正如标题中所述,我面临着非常好奇(也许不是这样)的行为.虽然我的程序在使用Keil编译时可以正常工作,但是当使用gcc编译相同的代码时,float变量的行为却很奇怪.
As said in the title I am facing quite curious (maybe not so) behavior. While my program works fine when compiled with Keil, float variables behave strangely when the same code is compiled with gcc.
在我的代码中,我用floatf printf变量:用Keil编译时,它给了我正确的值(即: float value = 0.15
,但用gcc时, printf
返回空白内容,例如: float value =
)
In my code, I printf the float variables : When compiled with Keil, it gives me the right values (i.e : float value = 0.15
but with gcc, the printf
returns blank stuff like : float value =
)
有人遇到这个问题吗?这是类型定义的问题吗?编译器选项?
Does anyone encountered the issue? Is it a matter of type definition? Compiler options?
正如P__J__所说:-u_printf_float是必需的.这样就解决了问题,谢谢
as P__J__ said : -u_printf_float is needed. This solved the issue, thank you
推荐答案
答案很简单.在大多数实现中,必须手动启用printf float支持,因为这会占用大量内存.
the answer is very easy. The printf float support has to be manually enabled in most implementations as it is memory consuming.
-lc -lrdimon -u _printf_float
这篇关于为什么float类型在Keil上能很好地工作而在Eclipse(gcc)上却不能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!