Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using 'FLT_EPSILON' for 64-bit iPhone 5S

I am getting the following error when trying to build my project using XCode 5.

Use of undeclared identifier 'FLT_EPSILON'

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

What am I doing wrong?


This is the code where FLT_EPSILON is used:

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

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

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

like image 285
GangstaGraham Avatar asked Oct 03 '13 03:10

GangstaGraham


2 Answers

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

That's a clang bug. Modules (-fmodules flag) are still experimental feature and when you mix Objective-C and C/C++ modules there can be some bugs.

See my demo project at github: TestEpsilon

First target use modules, the second one no. To ensure we got "clean" build I added DerivedData and ModulesCache cleanup in pre-build scripts.

like image 51
silvansky Avatar answered Nov 09 '22 21:11

silvansky


This worked for me:

#ifndef FLT_EPSILON
    #define FLT_EPSILON __FLT_EPSILON__
#endif

(this is how it's defined in float.h)

like image 2
Cam Saul Avatar answered Nov 09 '22 21:11

Cam Saul