Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dmatter

macrumors newbie
Original poster
Feb 7, 2013
2
0
I have a problem which sounds similar.
My code looks roughly like this:

.
.
#include <math.h>
.
.
uint8_t test;
isnan(test);
.

The error I get is "No matching function call to isnan".
For more context, the reason I'm chasing this down is because I'm using the PCL library and Xcode is giving me compile errors which seem to have this as their root cause.

I've tried adding the "Foundations" framework, which someone suggested somewhere, but that didn't help.
I've tried adding "/usr/bin/gcc" to my header search paths, but that hasn't worked either.

Any ideas or suggestions would be great.

Thanks!
 
Last edited by a moderator:

chown33

Moderator
Staff member
Aug 9, 2009
10,743
8,417
A sea of green
#include <math.h>
.
.
uint8_t test;
isnan(test);
.

The error I get is "No matching function call to isnan".

Even after this code compiles, it's still wrong.

First, the type of 'test' is uint8_t. That's not a floating-point type, so no NaN is possible. Any value that 'test' can possibly have is guaranteed to never be a NaN.

Second, isnan() returns a value. In the code shown, the return value of the function is neither tested nor assigned. It's just being ignored.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Even after this code compiles, it's still wrong.

First, the type of 'test' is uint8_t. That's not a floating-point type, so no NaN is possible. Any value that 'test' can possibly have is guaranteed to never be a NaN.

Second, isnan() returns a value. In the code shown, the return value of the function is neither tested nor assigned. It's just being ignored.

Yes, this. What I said probably isn't as important or relevant. Sorry about that.

Also, if you're having trouble compiling a specific library, there's likely discussions about that on the site you got the source from, or instructions.

For kicks, in math.h:
Code:
        #define isnan(x)        \
                (       sizeof (x) == sizeof(float )    ?       __inline_isnanf((float)(x))     \
                :       sizeof (x) == sizeof(double)    ?       __inline_isnand((double)(x))    \
                                                                                        :       __inline_isnan ((long double)(x)))
...
        static __inline__  int __inline_isnanf          (float      ) __MATH_H_ALWAYS_INLINE__;
        static __inline__  int __inline_isnand          (double     ) __MATH_H_ALWAYS_INLINE__;
        static __inline__  int __inline_isnan           (long double) __MATH_H_ALWAYS_INLINE__;
...
       static __inline__  int __inline_isnanf( float __x ) { return __x != __x; }
        static __inline__  int __inline_isnand( double __x ) { return __x != __x; }
        static __inline__  int __inline_isnan( long double __x ) { return __x != __x; }

Doing things the C way would end up with the long double version being used, which wouldn't go well. I was trying to look at the CPP versions, and it looks like there is some templating going on. I'm not positive if, eventually, this template leads to the macros. I'm not as hot with C++, so it wasn't quite as straight-forward.

If you actually try testing a floating-point value, though, you're much more likely to get things going, as chown33 said.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.