我需要做什么才能在 iOS 上使用 tgmath? [英] What do I need to do to use tgmath on iOS?

查看:33
本文介绍了我需要做什么才能在 iOS 上使用 tgmath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译我的第一个项目并启用 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).

根据这个问题的答案:

基于 CGFloat 的数学函数?

我只需要#include 来解决这个问题,并且可能将fabsf 更改为fabs.我至少有一个文件似乎没有帮助.我仍然收到警告:implicit conversion lost 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屋!

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