diff --git a/CMakeLists.txt b/CMakeLists.txt
index b87aa5052..017ca40c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,6 +58,11 @@ add_definitions("-DCOPYRIGHT=\"${COPYRIGHT}\"")
set(IDENTIFIER "com.${COMPANY}.${APPLICATION_NAME}")
add_definitions("-DIDENTIFIER=\"${IDENTIFIER}\"")
+add_compile_definitions(_USE_MATH_DEFINES)
+if(WIN32)
+ add_compile_definitions(NOMINMAX)
+endif()
+
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags
diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp
index f2d38561b..74a2769c9 100644
--- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp
+++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp
@@ -16,7 +16,6 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
#include
#include "device/deviceuiset.h"
diff --git a/plugins/channelrx/demodbfm/rdsdemod.cpp b/plugins/channelrx/demodbfm/rdsdemod.cpp
index 14d989c86..c14a3ed09 100644
--- a/plugins/channelrx/demodbfm/rdsdemod.cpp
+++ b/plugins/channelrx/demodbfm/rdsdemod.cpp
@@ -19,15 +19,10 @@
#include "../../channelrx/demodbfm/rdsdemod.h"
#include
-#include
+#include
#include
#include
-#undef M_PI
-#define M_PI 3.14159265358979323846
-#undef M_PI_2
-#define M_PI_2 1.57079632679489661923
-
const Real RDSDemod::m_pllBeta = 50;
const Real RDSDemod::m_fsc = 1187.5;
diff --git a/plugins/channelrx/demoddatv/leansdr/dvb.h b/plugins/channelrx/demoddatv/leansdr/dvb.h
index 66676f536..cedb8463c 100644
--- a/plugins/channelrx/demoddatv/leansdr/dvb.h
+++ b/plugins/channelrx/demoddatv/leansdr/dvb.h
@@ -17,17 +17,14 @@
#ifndef LEANSDR_DVB_H
#define LEANSDR_DVB_H
-#include
+#include
+#include
#include "leansdr/convolutional.h"
#include "leansdr/rs.h"
#include "leansdr/sdr.h"
#include "leansdr/viterbi.h"
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
namespace leansdr
{
diff --git a/plugins/channelrx/demoddatv/leansdr/math.h b/plugins/channelrx/demoddatv/leansdr/math.h
index 24fba2406..64bcbaaca 100644
--- a/plugins/channelrx/demoddatv/leansdr/math.h
+++ b/plugins/channelrx/demoddatv/leansdr/math.h
@@ -17,13 +17,9 @@
#ifndef LEANSDR_MATH_H
#define LEANSDR_MATH_H
-#include
+#include
#include
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
namespace leansdr
{
diff --git a/plugins/channelrx/demodnfm/nfmdemodsink.cpp b/plugins/channelrx/demodnfm/nfmdemodsink.cpp
index d51f02f0f..70cd50506 100644
--- a/plugins/channelrx/demodnfm/nfmdemodsink.cpp
+++ b/plugins/channelrx/demodnfm/nfmdemodsink.cpp
@@ -15,7 +15,7 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include
#include
diff --git a/plugins/channeltx/modpacket/packetmodbpfdialog.cpp b/plugins/channeltx/modpacket/packetmodbpfdialog.cpp
index c318d0658..0f7032f9c 100644
--- a/plugins/channeltx/modpacket/packetmodbpfdialog.cpp
+++ b/plugins/channeltx/modpacket/packetmodbpfdialog.cpp
@@ -15,7 +15,6 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
#include
#include "packetmodbpfdialog.h"
#include "ui_packetmodbpfdialog.h"
diff --git a/plugins/samplesource/testsource/testsourceworker.cpp b/plugins/samplesource/testsource/testsourceworker.cpp
index 188f7f704..4da7a74e0 100644
--- a/plugins/samplesource/testsource/testsourceworker.cpp
+++ b/plugins/samplesource/testsource/testsourceworker.cpp
@@ -15,9 +15,8 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
-#include
-#include
+#include
+#include
#include
#include "testsourceworker.h"
diff --git a/sdrbase/audio/audiocompressorsnd.h b/sdrbase/audio/audiocompressorsnd.h
index 712152db2..41d6f80fc 100644
--- a/sdrbase/audio/audiocompressorsnd.h
+++ b/sdrbase/audio/audiocompressorsnd.h
@@ -25,8 +25,7 @@
#ifndef SDRBASE_AUDIO_AUDIOCOMPRESSORSND_H_
#define SDRBASE_AUDIO_AUDIOCOMPRESSORSND_H_
-#define _USE_MATH_DEFINES
-#include
+#include
// maximum number of samples in the delay buffer
#define AUDIOCOMPRESSORSND_SF_COMPRESSOR_MAXDELAY 1024
@@ -161,7 +160,7 @@ private:
static inline float fixf(float v, float def){
// fix NaN and infinity values that sneak in... not sure why this is needed, but it is
- if (isnan(v) || isinf(v))
+ if (std::isnan(v) || std::isinf(v))
return def;
return v;
}
diff --git a/sdrbase/audio/audiofilter.cpp b/sdrbase/audio/audiofilter.cpp
index d6f01f5bd..9957b0f68 100644
--- a/sdrbase/audio/audiofilter.cpp
+++ b/sdrbase/audio/audiofilter.cpp
@@ -15,8 +15,7 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
-#include
+#include
#include
#include
diff --git a/sdrbase/dsp/afsquelch.cpp b/sdrbase/dsp/afsquelch.cpp
index faadf3074..1ebaa75a6 100644
--- a/sdrbase/dsp/afsquelch.cpp
+++ b/sdrbase/dsp/afsquelch.cpp
@@ -15,11 +15,9 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include "dsp/afsquelch.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
AFSquelch::AFSquelch() :
m_nbAvg(128),
diff --git a/sdrbase/dsp/ctcssdetector.cpp b/sdrbase/dsp/ctcssdetector.cpp
index df073562f..019c5a418 100644
--- a/sdrbase/dsp/ctcssdetector.cpp
+++ b/sdrbase/dsp/ctcssdetector.cpp
@@ -17,7 +17,6 @@
// along with this program. If not, see . //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
#include
#include "dsp/ctcssdetector.h"
diff --git a/sdrbase/dsp/fftfilt.h b/sdrbase/dsp/fftfilt.h
index 5c3e0222c..fa02d5432 100644
--- a/sdrbase/dsp/fftfilt.h
+++ b/sdrbase/dsp/fftfilt.h
@@ -6,12 +6,11 @@
#define _FFTFILT_H
#include
+#include
+
#include "gfft.h"
#include "export.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-
//----------------------------------------------------------------------
class SDRBASE_API fftfilt {
diff --git a/sdrbase/dsp/fftwindow.h b/sdrbase/dsp/fftwindow.h
index 1bcbb6bc1..32fbd7ca7 100644
--- a/sdrbase/dsp/fftwindow.h
+++ b/sdrbase/dsp/fftwindow.h
@@ -20,14 +20,10 @@
#define INCLUDE_FFTWINDOW_H
#include
-#define _USE_MATH_DEFINES
-#include
+#include
#include "dsp/dsptypes.h"
#include "export.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-
class SDRBASE_API FFTWindow {
public:
enum Function {
diff --git a/sdrbase/dsp/firfilter.h b/sdrbase/dsp/firfilter.h
index 0ba6334a5..d59cb3823 100644
--- a/sdrbase/dsp/firfilter.h
+++ b/sdrbase/dsp/firfilter.h
@@ -18,8 +18,7 @@
#pragma once
-#define _USE_MATH_DEFINES
-#include
+#include
#include "dsp/dsptypes.h"
#include "export.h"
diff --git a/sdrbase/dsp/fmpreemphasis.cpp b/sdrbase/dsp/fmpreemphasis.cpp
index 6e33ef431..0df31d38e 100644
--- a/sdrbase/dsp/fmpreemphasis.cpp
+++ b/sdrbase/dsp/fmpreemphasis.cpp
@@ -16,7 +16,6 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
#include
#include
#include "dsp/fmpreemphasis.h"
diff --git a/sdrbase/dsp/freqlockcomplex.cpp b/sdrbase/dsp/freqlockcomplex.cpp
index 59ce97e09..79a4e4018 100644
--- a/sdrbase/dsp/freqlockcomplex.cpp
+++ b/sdrbase/dsp/freqlockcomplex.cpp
@@ -22,8 +22,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include "freqlockcomplex.h"
-#define _USE_MATH_DEFINES
-#include
+#include
FreqLockComplex::FreqLockComplex() :
m_a0(0.998),
diff --git a/sdrbase/dsp/interpolator.cpp b/sdrbase/dsp/interpolator.cpp
index 467ed0a48..9ab79d84d 100644
--- a/sdrbase/dsp/interpolator.cpp
+++ b/sdrbase/dsp/interpolator.cpp
@@ -1,5 +1,4 @@
-#define _USE_MATH_DEFINES
-#include
+#include
#include
#include "dsp/interpolator.h"
diff --git a/sdrbase/dsp/misc.h b/sdrbase/dsp/misc.h
index eb0e411cf..f0c73f1f0 100644
--- a/sdrbase/dsp/misc.h
+++ b/sdrbase/dsp/misc.h
@@ -24,10 +24,7 @@
#ifndef _MISC_H
#define _MISC_H
-#include
-
-#undef M_PI
-#define M_PI 3.14159265358979323846
+#include
inline float sinc(float x)
{
diff --git a/sdrbase/dsp/nco.cpp b/sdrbase/dsp/nco.cpp
index 57d072327..6eda52fdb 100644
--- a/sdrbase/dsp/nco.cpp
+++ b/sdrbase/dsp/nco.cpp
@@ -17,13 +17,10 @@
///////////////////////////////////////////////////////////////////////////////////
#include
-#include
-#define _USE_MATH_DEFINES
-#include
+#include
+#include
#include "dsp/nco.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
Real NCO::m_table[NCO::TableSize];
bool NCO::m_tableInitialized = false;
diff --git a/sdrbase/dsp/ncof.cpp b/sdrbase/dsp/ncof.cpp
index 48011671c..4becab475 100644
--- a/sdrbase/dsp/ncof.cpp
+++ b/sdrbase/dsp/ncof.cpp
@@ -17,13 +17,9 @@
#include
#include
-#define _USE_MATH_DEFINES
-#include
+#include
#include "dsp/ncof.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-
Real NCOF::m_table[NCOF::TableSize+1];
bool NCOF::m_tableInitialized = false;
float NCOF::m_tableSizeLimit = (float) NCOF::TableSize;
diff --git a/sdrbase/dsp/phasediscri.h b/sdrbase/dsp/phasediscri.h
index e479c40e4..cb3059936 100644
--- a/sdrbase/dsp/phasediscri.h
+++ b/sdrbase/dsp/phasediscri.h
@@ -19,11 +19,9 @@
#ifndef INCLUDE_DSP_PHASEDISCRI_H_
#define INCLUDE_DSP_PHASEDISCRI_H_
+#include
#include "dsp/dsptypes.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-
class PhaseDiscriminators
{
public:
@@ -167,8 +165,8 @@ private:
}
- #define PI_FLOAT 3.14159265f
- #define PIBY2_FLOAT 1.5707963f
+ #define PI_FLOAT float(M_PI)
+ #define PIBY2_FLOAT float(M_PI_2)
// |error| < 0.005
float atan2_approximation2( float y, float x )
{
diff --git a/sdrbase/dsp/phaselock.cpp b/sdrbase/dsp/phaselock.cpp
index 503f85bca..035a2de17 100644
--- a/sdrbase/dsp/phaselock.cpp
+++ b/sdrbase/dsp/phaselock.cpp
@@ -16,11 +16,9 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include "dsp/phaselock.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
// Construct phase-locked loop.
PhaseLock::PhaseLock(Real freq, Real bandwidth, Real minsignal)
diff --git a/sdrbase/dsp/phaselockcomplex.cpp b/sdrbase/dsp/phaselockcomplex.cpp
index a5fdfe8ab..523469059 100644
--- a/sdrbase/dsp/phaselockcomplex.cpp
+++ b/sdrbase/dsp/phaselockcomplex.cpp
@@ -22,8 +22,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include
-#define _USE_MATH_DEFINES
-#include
+#include
#include "phaselockcomplex.h"
PhaseLockComplex::PhaseLockComplex() :
diff --git a/sdrbase/dsp/projector.cpp b/sdrbase/dsp/projector.cpp
index afe98ad5a..1add3dcf0 100644
--- a/sdrbase/dsp/projector.cpp
+++ b/sdrbase/dsp/projector.cpp
@@ -16,8 +16,7 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
-#include
+#include
#include "projector.h"
Projector::Projector(ProjectionType projectionType) :
diff --git a/sdrbase/dsp/raisedcosine.h b/sdrbase/dsp/raisedcosine.h
index 98a82bee2..5e9e51c18 100644
--- a/sdrbase/dsp/raisedcosine.h
+++ b/sdrbase/dsp/raisedcosine.h
@@ -19,8 +19,7 @@
#ifndef INCLUDE_RAISEDCOSINE_H
#define INCLUDE_RAISEDCOSINE_H
-#define _USE_MATH_DEFINES
-#include
+#include
#include "dsp/dsptypes.h"
// Raised-cosine low-pass filter for pulse shaping, without intersymbol interference (ISI)
diff --git a/sdrbase/dsp/recursivefilters.cpp b/sdrbase/dsp/recursivefilters.cpp
index f246e3ed2..d5f468943 100644
--- a/sdrbase/dsp/recursivefilters.cpp
+++ b/sdrbase/dsp/recursivefilters.cpp
@@ -15,12 +15,9 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#include
+#include
#include "recursivefilters.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-
SecondOrderRecursiveFilter::SecondOrderRecursiveFilter(float samplingFrequency, float centerFrequency, float r) :
m_r(r),
m_frequencyRatio(centerFrequency/samplingFrequency),
diff --git a/sdrbase/dsp/wfir.cpp b/sdrbase/dsp/wfir.cpp
index e6df32cd2..642bbe989 100644
--- a/sdrbase/dsp/wfir.cpp
+++ b/sdrbase/dsp/wfir.cpp
@@ -4,15 +4,13 @@
http://www.iowahills.com
*/
-#include
+#include
#include
#include
#include "wfir.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
-#define M_2PI 6.28318530717958647692
+#define M_2PI (2*M_PI)
// This first calculates the impulse response for a rectangular window.
// It then applies the windowing function of choice to the impulse response.
diff --git a/sdrbase/util/azel.cpp b/sdrbase/util/azel.cpp
index 4bb7494bb..7a9aeeb8b 100644
--- a/sdrbase/util/azel.cpp
+++ b/sdrbase/util/azel.cpp
@@ -17,7 +17,6 @@
#include "azel.h"
-#define _USE_MATH_DEFINES
#include
// Calculate cartesian distance between two points
diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h
index 3e01a3bf3..b8b5df5f6 100644
--- a/sdrgui/dsp/scopevis.h
+++ b/sdrgui/dsp/scopevis.h
@@ -25,7 +25,7 @@
#include
#include
-#include
+#include
#include
#include
@@ -37,8 +37,6 @@
#include "util/message.h"
#include "util/doublebuffer.h"
-#undef M_PI
-#define M_PI 3.14159265358979323846
class GLScope;
diff --git a/sdrgui/gui/fmpreemphasisdialog.cpp b/sdrgui/gui/fmpreemphasisdialog.cpp
index 54ddd80b6..37d1ef7a0 100644
--- a/sdrgui/gui/fmpreemphasisdialog.cpp
+++ b/sdrgui/gui/fmpreemphasisdialog.cpp
@@ -15,7 +15,6 @@
// along with this program. If not, see . //
///////////////////////////////////////////////////////////////////////////////////
-#define _USE_MATH_DEFINES
#include
#include "fmpreemphasisdialog.h"
#include "ui_fmpreemphasisdialog.h"