I looked into using tgmath.h
to deal with the CGFloat typedef float/double
mess when dealing with arm64.
This answer has a pretty good description of how to use it, except that it didn't work at all for me. No matter what, my code was still calling the math.h
functions.
After spending some time looking at all of the project compiler settings, I found that disabling the "Modules" feature (@import vs #import - iOS 7) makes it all work. More specifically, the option in the project settings is called Enable Modules(C and Objective-C)
in the Apple LLVM 5.1 - Language - Modules
dropdown.
To see a quick example of this issue, download a project that uses tgmath, such as MBProgressHUD, and see what happens when you enable the modules project setting. The tgmath.h
calls get replaced with regular math.h
calls.
My question is:
Why do modules prevent tgmath from being imported properly?
Is there a way to get around it and use both tgmath and modules? I would like to still be able to use them.
I'm not sure what's causing the issue, but as a workaround you could at least disable modules for only the file(s) where you're using tgmath.h
:
-fno-modules
in the Compiler Flags popover to disable Clang modules for that file.At least this way you would still get the benefits of modules in most of your project. (This is assuming, of course, you don't need tgmath.h
in the majority of your source files.)
It might already be in your math library under the name ctgmath: Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With