mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
On MSVC the `M_` constants are hidden behind the `USE_MATH_DEFINES` macro, so it's better to avoid them in headers otherwise the include order can break compilation. Pull Request resolved: https://github.com/pytorch/pytorch/pull/91967 Approved by: https://github.com/malfet
17 lines
440 B
C++
17 lines
440 B
C++
// define constants like M_PI and C keywords for MSVC
|
|
#ifdef _MSC_VER
|
|
#ifndef _USE_MATH_DEFINES
|
|
#define _USE_MATH_DEFINES
|
|
#endif
|
|
#endif
|
|
|
|
#include <c10/util/MathConstants.h>
|
|
|
|
// NOLINTNEXTLINE(modernize-deprecated-headers)
|
|
#include <math.h>
|
|
|
|
static_assert(M_PI == c10::pi<double>, "c10::pi<double> must be equal to M_PI");
|
|
static_assert(
|
|
M_SQRT1_2 == c10::frac_sqrt_2<double>,
|
|
"c10::frac_sqrt_2<double> must be equal to M_SQRT1_2");
|