From 14696c23d900843e61ba1453dc34065e3b6e25e3 Mon Sep 17 00:00:00 2001 From: Yves Gerey Date: Thu, 11 Apr 2019 13:51:10 +0200 Subject: [PATCH] [Cleanup] Remove our own definition of M_PI. * This is too brittle and might clash with MSVC's M_PI. See [1]. * We only used it once (in a unit test). * We shouldn't use PI anyway [2]. Instead, pull it from with _USE_MATH_DEFINES, like it's already done in the code base. [1] https://ci.chromium.org/p/webrtc/builders/try/win_x86_msvc_rel/6844 [2] https://tauday.com/tau-manifesto Bug: webrtc:9855 Change-Id: I7a6976240604ef367ea07478d8cb5e4020e5dfeb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132548 Reviewed-by: Alessio Bazzica Reviewed-by: Harald Alvestrand Commit-Queue: Yves Gerey Cr-Commit-Position: refs/heads/master@{#27597} --- modules/audio_processing/rms_level_unittest.cc | 3 ++- rtc_base/numerics/math_utils.h | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/audio_processing/rms_level_unittest.cc b/modules/audio_processing/rms_level_unittest.cc index c2d6a507ff..67489de08e 100644 --- a/modules/audio_processing/rms_level_unittest.cc +++ b/modules/audio_processing/rms_level_unittest.cc @@ -7,6 +7,8 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +// MSVC++ requires this to be set before any other includes to get M_PI. +#define _USE_MATH_DEFINES #include #include #include @@ -14,7 +16,6 @@ #include "api/array_view.h" #include "modules/audio_processing/rms_level.h" #include "rtc_base/checks.h" -#include "rtc_base/numerics/math_utils.h" #include "rtc_base/numerics/safe_conversions.h" #include "test/gtest.h" diff --git a/rtc_base/numerics/math_utils.h b/rtc_base/numerics/math_utils.h index d5f3ee4073..4bf48e22bb 100644 --- a/rtc_base/numerics/math_utils.h +++ b/rtc_base/numerics/math_utils.h @@ -11,15 +11,11 @@ #ifndef RTC_BASE_NUMERICS_MATH_UTILS_H_ #define RTC_BASE_NUMERICS_MATH_UTILS_H_ -#include +#include #include #include "rtc_base/checks.h" -#ifndef M_PI -#define M_PI 3.14159265359f -#endif - // Given two numbers |x| and |y| such that x >= y, computes the difference // x - y without causing undefined behavior due to signed overflow. template