Closed pierreinglebert closed 4 years ago
It's trying to return infinity or nan here.
Since this function should be C90 compatible, unfortunately the INFINITY or NAN macros are not available.
I'll look into finding a better way that's compatible with C90, visual studio and all other platforms.
Does commit 3e74e9f fix it?
Maybe?:
static const float lodepng_flt_inf = 0x7FF00000;
static const float lodepng_flt_nan = 0x7FFF0000;
That one would assign values 2146435072.0 and 2147418112.0 to the floats. With bit (aka reinterpret) casting that would work, but such bit cast has about as many portability issues than the division through 0.0 solution, if not more due to endianness and depending on exact IEEE bit representation.
@lvandeve say:
but such bit cast has about as many portability
Can just write an auxiliary function for checking conditions? And execute entire sections of code by condition?
If the current proposed solution works, it's simpler, platform dependent #ifdefs are a next step if the current idea doesn't fix it.
I'd just like to double check that the current solution fixes it for VS users: whether the static const lodepng_fltzero works, or if it should be not static and/or not const for VS to not give error.
Commit 6bef71b33f90f716a5f16047e2127439f622d1ba should fix it fully, closing the issue with this assumption
While removing powf.h, you added some division by zero (line 299) that breaks when compiling with VS
error C2124: divide or mod by zero