Ben Pfaff wrote:
> (David Green) writes:
>
>
>>const.c(92) : error C2099: initializer is not a constant
>>const.c(97) : error C2099: initializer is not a constant
>>
>>with the relevant lines of the const.c code being:
>>
>>ln 92 double INFINITY = 1.0/0.0; /* 99e999; */
>>ln 97 double NAN = 1.0/0.0 - 1.0/0.0;
>
>
> Both of these invoke undefined behavior due to division by zero.
> Maybe that's why the compiler regards them as not being constant
> expressions. I can't think of another reason right now.
>
> If your implementation has a C99-compliant <math.h>, you can just
> #include <math.h> to get ready-made macros for these.
He did mention that he's using Visual C, which does not (to the best of
my knowledge) support C99 (though it apparently supports it in some
ways, and it's certainly possible that this is one of them).
To the best of my knowledge, outside of C99 there is not a portable way
to generate INF and NAN. But there's probably a system-specific way. I'd
recommend checking the documentation for a function or a predefined
constant.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.