[NumPy-Tickets] [NumPy] #1502: isnan and isinf not defined when using msvc9

NumPy Trac numpy-tickets@scipy....
Thu Jun 3 20:44:10 CDT 2010


#1502: isnan and isinf not defined when using msvc9
---------------------+------------------------------------------------------
 Reporter:  cgohlke  |       Owner:  somebody
     Type:  defect   |      Status:  new     
 Priority:  normal   |   Milestone:  2.0.0   
Component:  Other    |     Version:  devel   
 Keywords:           |  
---------------------+------------------------------------------------------
 Changeset r8455, "BUG: fix missing macros definition for IEEE macros",
 breaks the build process on Windows when using Visual Studio 2008.

 The changes in r8455 look correct. The problem is that for some reason
 NPY_HAVE_DECL_ISNAN and NPY_HAVE_DECL_ISINF are defined in Python's
 pyconfig.h header, but the macros isnan and isinf are not. Visual Studio
 does not have these C99 macros/functions either, so the numpy build fails
 with "unresolved external symbol isnan" and "...isinf".

 A workaround might be to use the msvc functions _isnan() and _finite() in
 npy_math.h:

 {{{
 #ifndef NPY_HAVE_DECL_ISNAN
     #define npy_isnan(x) ((x) != (x))
 #else
     #ifdef _MSC_VER
         #define npy_isnan(x) _isnan((x))
     #else
         #define npy_isnan(x) isnan((x))
     #endif
 #endif

 #ifndef NPY_HAVE_DECL_ISFINITE
     #ifdef _MSC_VER
         #define npy_isfinite(x) _finite((x))
     #else
         #define npy_isfinite(x) !npy_isnan((x) + (-x))
     #endif
 #else
     #define npy_isfinite(x) isfinite((x))
 #endif

 #ifndef NPY_HAVE_DECL_ISINF
     #define npy_isinf(x) (!npy_isfinite(x) && !npy_isnan(x))
 #else
     #ifdef _MSC_VER
         #define npy_isinf(x) (!_finite(x) && !_isnan(x))
     #else
         #define npy_isinf(x) isinf((x))
     #endif
 #endif
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1502>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list