Search code examples
iosarm64tgmath

What do I need to do to use tgmath on iOS?


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).

According to the answer on this question:

CGFloat-based math functions?

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.


Solution

  • I was able to get the tgmath.h functions to work by including the header at the top of my PCH file.

    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.