diff options
author | Steven Koo <steven.koo@ni.com> | 2020-08-06 21:18:17 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-08-07 07:24:16 -0500 |
commit | 6c213ecd0927d10a98ba6ec64fbc9338516edee2 (patch) | |
tree | e7a399c18df941c2b2234cdb763f61f2f047ce02 /host/include | |
parent | 0df2f9932cc270b8f1a705ea2543df8792005878 (diff) | |
download | uhd-6c213ecd0927d10a98ba6ec64fbc9338516edee2.tar.gz uhd-6c213ecd0927d10a98ba6ec64fbc9338516edee2.tar.bz2 uhd-6c213ecd0927d10a98ba6ec64fbc9338516edee2.zip |
rfnoc: Remove M_PI usage to fix Windows builds
M_PI may not exist if _USE_MATH_DEFINES isn't defined before the
first include of math.h or cmath on Windows. This changes avoids the
issue all together by defining our own PI.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/rfnoc/siggen_block_control.hpp | 7 | ||||
-rw-r--r-- | host/include/uhd/utils/math.hpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/host/include/uhd/rfnoc/siggen_block_control.hpp b/host/include/uhd/rfnoc/siggen_block_control.hpp index 944ecc4e0..e599659b6 100644 --- a/host/include/uhd/rfnoc/siggen_block_control.hpp +++ b/host/include/uhd/rfnoc/siggen_block_control.hpp @@ -6,10 +6,9 @@ #pragma once -#define _USE_MATH_DEFINES #include <uhd/config.hpp> #include <uhd/rfnoc/noc_block_base.hpp> -#include <cmath> +#include <uhd/utils/math.hpp> #include <complex> namespace uhd { namespace rfnoc { @@ -195,8 +194,8 @@ public: if (sample_rate <= 0.0) { throw uhd::value_error("sample_rate must be > 0.0"); } - const double phase_inc = (frequency / sample_rate) * 2.0 * M_PI; - if (phase_inc < -M_PI || phase_inc > M_PI) { + const double phase_inc = (frequency / sample_rate) * 2.0 * uhd::math::PI; + if (phase_inc < -uhd::math::PI || phase_inc > uhd::math::PI) { throw uhd::value_error("frequency must be in [-samp_rate/2, samp_rate/2]"); } set_sine_phase_increment(phase_inc, port); diff --git a/host/include/uhd/utils/math.hpp b/host/include/uhd/utils/math.hpp index d442d6a94..becc256f1 100644 --- a/host/include/uhd/utils/math.hpp +++ b/host/include/uhd/utils/math.hpp @@ -30,6 +30,8 @@ namespace uhd { */ namespace math { +static const double PI = 3.14159265358979323846; + /*! * Define epsilon values for floating point comparisons. * |