diff --git a/mlx/ops.cpp b/mlx/ops.cpp index 13ae53f76..577a17851 100644 --- a/mlx/ops.cpp +++ b/mlx/ops.cpp @@ -1,4 +1,8 @@ // Copyright © 2023-2024 Apple Inc. + +// Required for using M_PI in MSVC. +#define _USE_MATH_DEFINES + #include #include #include diff --git a/mlx/primitives.cpp b/mlx/primitives.cpp index 06be5f2a5..7acb4129c 100644 --- a/mlx/primitives.cpp +++ b/mlx/primitives.cpp @@ -1,4 +1,8 @@ // Copyright © 2023-2024 Apple Inc. + +// Required for using M_2_SQRTPI in MSVC. +#define _USE_MATH_DEFINES + #include #include #include diff --git a/tests/autograd_tests.cpp b/tests/autograd_tests.cpp index 9b763ec8b..3fe839ca5 100644 --- a/tests/autograd_tests.cpp +++ b/tests/autograd_tests.cpp @@ -1,5 +1,8 @@ // Copyright © 2023 Apple Inc. +// Required for using M_2_SQRTPI in MSVC. +#define _USE_MATH_DEFINES + #include #include #include diff --git a/tests/compile_tests.cpp b/tests/compile_tests.cpp index 5bcba68f4..9ca4cf19f 100644 --- a/tests/compile_tests.cpp +++ b/tests/compile_tests.cpp @@ -1,5 +1,8 @@ // Copyright © 2023-2024 Apple Inc. +// Required for using M_SQRT2 in MSVC. +#define _USE_MATH_DEFINES + #include "doctest/doctest.h" #include "mlx/mlx.h" diff --git a/tests/ops_tests.cpp b/tests/ops_tests.cpp index 9d87b8e2c..3b9a11e6f 100644 --- a/tests/ops_tests.cpp +++ b/tests/ops_tests.cpp @@ -1,4 +1,8 @@ // Copyright © 2023-2024 Apple Inc. + +// Required for using M_PI_2 in MSVC. +#define _USE_MATH_DEFINES + #include #include