Cannot build tests on MSVC
SegaraRai opened this issue ยท 3 comments
MSVC displayed following error when I tried to build vorbis with CMake.
vorbis\test\util.c(37,41): error C2065: "M_PI": undeclared identifier
MSVC seems to require #define _USE_MATH_DEFINES
before #include <math.h>
to use M_PI
.
Build succeeded once I add it to L16.
I see. M_PI
is also referenced by several files in lib
but the library source generally includes os.h
which has a fallback definition of M_PI
for MSVC. The tone
utility should have the same problem, but it looks like the CMake build doesn't try to compile it.
gcc enables M_PI by default as a gnu extension (part of X/Open) In my editor, clang-complete also complains about the missing definition.
So defining _USE_MATH_DEFINES
here, possibly protected by an #ifdef MSVC
is probably the correct fix, but it might be better to change the line in os.h
similarly. tone.c
can just include os.h since it's internal to the library source.
And obviously we should add the building and running the tests to the appveyor config!