Using FLT_EPSILON for a 64-bit iPhone 5S

I get the following error when trying to build my project using Xcode 5.

Use of undeclared identifier 'FLT_EPSILON' 

I checked, and FLT_EPSILON (it appears brown in Xcode) is defined in the file "float.h".

What am I doing wrong?


This is the code that uses FLT_EPSILON:

 if (someTimeInterval < 0.03 - FLT_EPSILON) { someTimeInterval = 0.1; } 

I realized that this was because I was trying to test it on the iPhone 5S simulator (64 BIT).

I do not understand the differences very well when using a 64-bit simulator. What should I include instead of FLT_EPSILON - and why doesn't it work with 64 bits?

+6
source share
3 answers

I do not know why this did not work only for 64-bit devices.

But here is the solution:

Make sure MobileCoreServices.framework is set and then it should work fine

Import <MobileCoreServices/MobileCoreServices.h>

+1
source

The solution is to disable the modules in your project. To do this, go to the build settings and set the Enable Modules option to None.

This is a clang error. Modules (the -fmodules flag) are still an experimental function, and when you mix Objective-C and C / C ++ modules, there may be some errors.

See my demo project on github: TestEpsilon

The first target modules, the second - no. To make sure we got a clean build, I added a cleanup of DerivedData and ModulesCache in pre-build scripts.

+3
source

This worked for me:

 #ifndef FLT_EPSILON #define FLT_EPSILON __FLT_EPSILON__ #endif 

(as defined in float.h )

+2
source

Source: https://habr.com/ru/post/955159/


All Articles