From 678e872c2124ec5175106616881f7df41be66647 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Thu, 4 Mar 2021 18:39:19 +0100 Subject: BUILD(cmake): Always define _USE_MATH_DEFINES This is needed in order for the header to also define constants like M_PI. Instead of manually defining the macro every time before including , the macro is now defined via cmake and thus always defined. --- CMakeLists.txt | 3 +++ plugins/mumble_plugin_win32.h | 1 - src/mumble/AudioOutput.cpp | 10 ++-------- src/mumble/AudioOutputSpeech.cpp | 12 ++---------- src/mumble/ManualPlugin.cpp | 5 +---- src/murmur/murmur_pch.h | 4 ---- src/tests/Resample.cpp | 2 -- 7 files changed, 8 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 856d1eca1..47b88ab7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,9 @@ endif() # Make the build year accessible as a macro add_compile_definitions(MUMBLE_BUILD_YEAR=${MUMBLE_BUILD_YEAR}) +# Make sure that math constants are always defined +add_compile_definitions(_USE_MATH_DEFINES) + add_subdirectory(src) if(g15 AND WIN32) diff --git a/plugins/mumble_plugin_win32.h b/plugins/mumble_plugin_win32.h index fd101e954..b2d530579 100644 --- a/plugins/mumble_plugin_win32.h +++ b/plugins/mumble_plugin_win32.h @@ -10,7 +10,6 @@ # error "Include mumble_plugin_main.h instead of mumble_plugin_win32.h" #endif -#define _USE_MATH_DEFINES #include #include // Define "NOMINMAX" only if it isn't already. diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index a52cc393b..d177103c9 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -3,14 +3,6 @@ // that can be found in the LICENSE file at the root of the // Mumble source tree or at . -// includes , but only if it isn't already included. -// We include as first header to make sure that we include with _USE_MATH_DEFINES. -#ifdef _MSC_VER -# define _USE_MATH_DEFINES -#endif - -#include - #include "AudioOutput.h" #include "AudioInput.h" @@ -29,6 +21,8 @@ #include "VoiceRecorder.h" #include "Global.h" +#include + // Remember that we cannot use static member classes that are not pointers, as the constructor // for AudioOutputRegistrar() might be called before they are initialized, as the constructor // is called from global initialization. diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp index a0f28579d..ee7426a1e 100644 --- a/src/mumble/AudioOutputSpeech.cpp +++ b/src/mumble/AudioOutputSpeech.cpp @@ -3,16 +3,6 @@ // that can be found in the LICENSE file at the root of the // Mumble source tree or at . -// We want to include with _USE_MATH_DEFINES defined. -// To make sure we do so before anything else includes the header without it -// (triggering the guard and effectively preventing a "fix include") -// we define and include before anything else. -#ifdef _MSC_VER -# define _USE_MATH_DEFINES -#endif - -#include - #include "AudioOutputSpeech.h" #include "Audio.h" @@ -26,6 +16,8 @@ #include "Utils.h" #include "Global.h" +#include + AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, MessageHandler::UDPMessageType type, unsigned int systemMaxBufferSize) : AudioOutputUser(user->qsName) { diff --git a/src/mumble/ManualPlugin.cpp b/src/mumble/ManualPlugin.cpp index 38eae17c1..34e185f65 100644 --- a/src/mumble/ManualPlugin.cpp +++ b/src/mumble/ManualPlugin.cpp @@ -3,8 +3,6 @@ // that can be found in the LICENSE file at the root of the // Mumble source tree or at . -#define _USE_MATH_DEFINES - #include #include #include @@ -14,6 +12,7 @@ #include #include +#include #include "../../plugins/mumble_plugin.h" #include "Global.h" @@ -416,5 +415,3 @@ MumblePlugin *ManualPlugin_getMumblePlugin() { MumblePluginQt *ManualPlugin_getMumblePluginQt() { return &manualqt; } - -#undef _USE_MATH_DEFINES diff --git a/src/murmur/murmur_pch.h b/src/murmur/murmur_pch.h index b900346a0..f10f718a8 100644 --- a/src/murmur/murmur_pch.h +++ b/src/murmur/murmur_pch.h @@ -7,10 +7,6 @@ # ifndef MUMBLE_MURMUR_MURMUR_PCH_H_ # define MUMBLE_MURMUR_MURMUR_PCH_H_ -# ifdef _MSC_VER -# define _USE_MATH_DEFINES -# endif - # include # ifdef Q_OS_WIN diff --git a/src/tests/Resample.cpp b/src/tests/Resample.cpp index ec0f256cd..be9fe30d8 100644 --- a/src/tests/Resample.cpp +++ b/src/tests/Resample.cpp @@ -15,7 +15,6 @@ #include -#define _USE_MATH_DEFINES #include #include @@ -132,5 +131,4 @@ int main(int argc, char **argv) { return 0; } -#undef _USE_MATH_DEFINES #undef ITER -- cgit v1.2.3