Blitz logo

Blitz Support :

From: Julian Cummings (cummings_at_[hidden])
Date: 2005-05-18 18:10:15


Hello Zane,

Thank you for your input. This autoconf macro will definitely find
isnan whether it is a macro or not, but it doesn't distinguish between
the two. The other problem is that many systems actually have both a
normal function and a macro that overrides it (and does the same thing,
hopefully!). So your autoconf macro would find isnan in the C standard
library and just stop right there, without ever checking if it was
defined in <math.h>.

The only reason this stuff matters is that in blitz we are calling these
functions from within the blitz namespace. The <cmath> header is
supposed to provide safe access to math functions through the std
namespace. If it does this, then you really must use std::isnan from
within the blitz namespace. If it doesn't provide the name in the std
namespace, then you should say ::isnan like you would with other
functions that are floating around in the global namespace. Only that
doesn't work when isnan is a macro function! Ugh! Fortunately, I think
I have this all sorted out now by checking for std::isnan and using that
if it exists.

Regards, Julian C.

On Wed, 2005-05-18 at 13:42 -0500, Zane Dodson wrote:

> Here is what I have used in the past.
>
> dnl === Checks for specific functions
>
> dnl ==== isnan ====
> dnl ===== Could be a macro or a function. C99 requires a macro.
> AC_LANG_PUSH([C])
> AC_CHECK_FUNCS([isnan])
> if test $ac_cv_func_isnan = no; then
> # isnan not in default libraries; try as a macro.
> AC_MSG_RESULT([for isnan macro])
> AC_TRY_LINK([#include <math.h>],
> [{int tmp = isnan(0);}],
> [ac_cv_func_isnan=yes],
> [ac_cv_func_isnan=no])
> if test $ac_cv_func_isnan = yes; then
> AC_MSG_RESULT([yes])
> AC_DEFINE([HAVE_ISNAN])
> else
> AC_MSG_RESULT([no])
> fi
> fi
>
> Kindest regards,
>
> --
> Zane Dodson
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>

-- 
Dr. Julian C. Cummings                       E-mail: cummings_at_[hidden]
California Institute of Technology           Phone:  626-395-2543
1200 E. California Blvd., Mail Code 158-79   Fax:    626-584-5917
Pasadena, CA 91125                           Office: 125 Powell-Booth