在iOS上使用tgmath我需要怎么做? [英] What do I need to do to use tgmath on iOS?
问题描述
我正在编译启用了64位支持的第一个项目.我遇到一堆有关隐式转换为浮动的编译器警告.之所以发生这种情况,是因为我正在使用fabsf()并将结果分配给CGFloat(这是两倍,而不是在新的64位体系结构上浮动).
I'm compiling my first project with 64 bit support enabled. I'm running into a bunch of compiler warnings about implicit conversions to float. This is happening because I'm using fabsf() and assigning the result to a CGFloat (which is a double, not float on the new 64 bit architecture).
根据该问题的答案:
我只需要#include <tgmath.h>
即可解决此问题,并且可能将fabsf
更改为fabs
.我至少有一个文件似乎没有帮助.我仍然收到警告:implicit conversion loses floating-point precision 'double' to 'CGFloat' aka (float).
这是生成该警告的行:
I just need to #include <tgmath.h>
to solve this problem and probably change fabsf
to fabs
. I have at least one file where this doesn't seem to be helping. I still get the warning: implicit conversion loses floating-point precision 'double' to 'CGFloat' aka (float).
Here's the line that generates that warning:
CGFloat deltaX = fabs(item.center.x-point.x);
还有其他人遇到吗?您是如何解决的?我宁愿不禁用此警告,也不用大量类型转换来浪费我的代码.
Has anyone else run across this? How did you solve it? I'd rather not disable this warning or litter my code with a ton of typecasts.
推荐答案
通过在PCH文件顶部添加标头,我能够使用tgmath.h
函数.
I was able to get the tgmath.h
functions to work by including the header at the top of my PCH file.
在某个时候(阅读:Xcode更新),我不得不开始禁用模块才能使其正常工作.此类的详细信息位于> Dima链接至以下内容
At some point (read: Xcode update) I had to start disabling Modules to get this to work. The details of such are in the question Dima links to below.
这篇关于在iOS上使用tgmath我需要怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!