Closed anntzer closed 3 years ago
I'm ready to merge this, but the appveyor build fails. Can you check how to get tgmath.h on VS2015?
tgmath.h is actually C11. Can we keep the code compatible with C99?
https://docs.microsoft.com/en-us/cpp/c-runtime-library/tgmath?view=msvc-160
/std:c11
). There must be a similar flag for clang/gcc#if __STDC_VERSION__ >= 201112L
Interestingly enough, cppreference says that tgmath.h is C99. Well, I can try to use the #define foo(x) foof(x)
approach instead...
Hum yeah this is ambiguous. Maybe all we need is to add C99 flags to the build? can you try that instead?
Actually the #define
approach is better because you catch even more places where floats got accidentally promoted to doubles (tgmath silently calls the double version for you).
The first commit switches from using
math.h
totgmath.h
. This means that the single precision variants will use e.g.sqrtf
instead of casting todouble
, callingsqrt
, and casting back tofloat
. Hopefully this should be slighly faster, although I have admittedly not performed any profiling. This also makes the manual definition of#define foo(x) fool(x)
for the longdouble case unnecessary. (Instead of usingtgmath.h
I could also have use#define foo(x) foof(x)
in the float case, buttgmath.h
seemed completely suitable for this use case...)I made sure that nothing was missed by compiling with gcc's
-Wconversion
option. In the second commit I added a few more manual casts to suppress other instances of-Wconversion
.