View Single Post
Posts: 839 | Thanked: 3,386 times | Joined on Mar 2009
#1
When compiling code on scratchbox2 I got
error: 'NAN' undeclared
and
error: 'INFINITY' undeclared

I made simple test case, and it seems there are no defined NAN or INFINITY.

Same code complies under Ubuntu. I checked math.h and nan.h.

Code:
diff -u /usr/include/math.h ~/.maemo-sdk/rootstraps/armel/fremantle5.0minimal_armel/usr/include/math.h
diff -u /usr/include/bits/nan.h ~/.maemo-sdk/rootstraps/armel/fremantle5.0minimal_armel/usr/include/bits/nan.h
nan.h is identical. math.h differs on comments.



Code with workaround. Why this workaround is needed?
Code:
#include <math.h>

//Workaround:
#ifndef NAN
#define NAN (0.0/0.0)
#endif 

//Workaround:
#ifndef INFINITY
#define INFINITY (1.0/0.0)
#endif 

int main() {
  printf("NAN: %f\n",NAN);
  printf("INFINITY: %f\n",INFINITY);
  return 0;
}