Re: Strange things in math.h under Intel OSX
Shantonu Sen <[email protected]> Fri, 19 May 2006 06:30:18 -0700
| Newsgroups | gmane.os.opendarwin.general |
|---|---|
| Message-ID | <[email protected]> |
Sounds like a bug. You should report it as such at <http://bugreporter.apple.com > Shantonu On May 19, 2006, at 4:06 AM, Max Persson wrote: > Hi there, > > It seems like Apple may have done some mistakes in their port > of the standard c library (which I seriously doubt). I bumped in to > this problem when I compiled > some tests for OpenEXR (under Intel OS X on a MacBook Pro). It says > that a function from math.h is invalid. As you may know, there are two > versions of some of the stuff in the std-c library, one for ppc and > the other for i386. math.h is one of them. There is a macro/function > called isnan() that determines if a float is a number or not, and it > was here I bumped into the strange things. I opened up both versions > of math.h and compared the implementation of the isnan() macro... > > > Here is the one in the i386 math.h: > > #define isnan(x) \ > ( sizeof (x) == sizeof(float ) ? __isnanf > (x) \ > : sizeof (x) == sizeof(double) ? __isnand > (x) \ > > : __isnan (x)) > > > And here is the one from the ppc math.h: > > #define isnan( x ) ( ( sizeof ( (x) ) == sizeof(double) ) > ? \ > __isnand ( (double)(x) ) : > \ > ( sizeof ( (x) ) == sizeof( float) ) ? > \ > __isnanf ( (float)(x) ) : > \ > __isnan ( ( long double )(x) ) ) > > > The one that is used in my particular case is the first of them as I > am on a i386 OS X. What I have learnt, you always put surrounding > parenthesis in macros to prevent them from failing due to strange > input. That is NOT the case in the i386 math.h (along with a couple of > other macros there too). > > > The input argument in the call to the isnan() macro is in this case: > > isnan(pf[y][x]) > > > What I belive is happening here is that the macro gets very confused > with the array access here, because of the missing input parenthesis > in the macro. This is what I got from the compiler to further > strengthen the theory: > > testTiledCompression.cpp:59: error: expected unqualified-id before > 'sizeof' > testTiledCompression.cpp:59: error: expected `)' before 'sizeof' > > > But enough talking about this. I do not look for a quick fix here, > what I'm concerned about is that Apple may have delivered a faulty > math.h file for the Intel version of OS X. What do you think about it? > > > Kind regards, > Max Persson > > MFX AB, Sweden > www.mfx.se > _______________________________________________ > Discuss mailing list > [email protected] > http://www.opendarwin.org/mailman/listinfo/discuss