summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Giles <giles@thaumas.net>2021-05-09 11:31:21 -0700
committerRalph Giles <giles@thaumas.net>2021-05-09 11:45:06 -0700
commitc7b63a76a28c8700c76b04143b200d33a110b22d (patch)
tree76219ab6a36bf2ed7ca782badee14705e7eeb009
parent4e1155cc77a2c672f3dd18f9a32dbf1404693289 (diff)
downloadlibvorbis-git-math_defines.tar.gz
Set _USE_MATH_DEFINES for MSVC builds.math_defines
Add this define to lib/os.h and test/util.c so M_PI is available when building with Microsoft's math.h. On other systems, it's typically enabled by default, e.g. through __USE_XOPEN or __USE_GNU. We already had a fallback definition of M_PI in os.h which was used by the core library, but not included in the test harness, which failed to compile under CMake and MSVC. Using the system define should be more consistent. Based on a patch by Ozkan Sezer.
-rw-r--r--lib/os.h4
-rw-r--r--test/util.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/os.h b/lib/os.h
index 9ded7358..f0947dc9 100644
--- a/lib/os.h
+++ b/lib/os.h
@@ -20,6 +20,10 @@
#include "config.h"
#endif
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+
#include <math.h>
#include <ogg/os_types.h>
diff --git a/test/util.c b/test/util.c
index 3dc1597c..1eb95e13 100644
--- a/test/util.c
+++ b/test/util.c
@@ -14,6 +14,10 @@
********************************************************************/
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <math.h>