From 142f0f29cd0c863e6cda7a43efaef17d5f14a48b Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 11:17:03 +0200 Subject: [PATCH 01/16] MSVC: Fix compiler warning flags --- CMakeLists.txt | 70 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7969fd9b084..69083361e00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0026 OLD) CMAKE_POLICY(SET CMP0050 OLD) ENDIF() + CMAKE_POLICY(SET CMP0020 NEW) ENDIF(COMMAND CMAKE_POLICY) INCLUDE(AddFileDependencies) @@ -300,13 +301,13 @@ ENDIF(WANT_PORTAUDIO) IF(WANT_SOUNDIO) FIND_PACKAGE(SoundIo) IF(SOUNDIO_FOUND) - SET(LMMS_HAVE_SOUNDIO TRUE) - SET(STATUS_SOUNDIO "OK") - INCLUDE_DIRECTORIES("${SOUNDIO_INCLUDE_DIR}") + SET(LMMS_HAVE_SOUNDIO TRUE) + SET(STATUS_SOUNDIO "OK") + INCLUDE_DIRECTORIES("${SOUNDIO_INCLUDE_DIR}") ELSE(SOUNDIO_FOUND) - SET(SOUNDIO_INCLUDE_DIR "") - SET(STATUS_SOUNDIO "not found, please install libsoundio if you require libsoundio support") - SET(SOUNDIO_LIBRARY "") + SET(SOUNDIO_INCLUDE_DIR "") + SET(STATUS_SOUNDIO "not found, please install libsoundio if you require libsoundio support") + SET(SOUNDIO_LIBRARY "") ENDIF(SOUNDIO_FOUND) ENDIF(WANT_SOUNDIO) @@ -473,24 +474,34 @@ ENDIF(WANT_DEBUG_FPE) # check for libsamplerate PKG_CHECK_MODULES(SAMPLERATE REQUIRED samplerate>=0.1.8) + +message("Compiler: ${CMAKE_CXX_COMPILER_ID} Is MSVC: ${MSVC} Version: ${MSVC}") # set compiler flags -SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow") -OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF) -IF(${USE_WERROR}) - SET(WERROR_FLAGS "${WERROR_FLAGS} -Werror") -ENDIF() +IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) + SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow") + OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF) + IF(${USE_WERROR}) + SET(WERROR_FLAGS "${WERROR_FLAGS} -Werror") + ENDIF() -# Due to a regression in gcc-4.8.X, we need to disable array-bounds check -IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32)) - SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds") + # Due to a regression in gcc-4.8.X, we need to disable array-bounds check + IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32)) + SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds") + ENDIF() +ELSE() + SET(WERROR_FLAGS "/W2") + IF(${USE_WERROR}) + SET(WERROR_FLAGS "${WERROR_FLAGS} /WX") + ENDIF() ENDIF() + IF(NOT CMAKE_BUILD_TYPE) message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" - "MinSizeRel" "RelWithDebInfo") + "MinSizeRel" "RelWithDebInfo") ENDIF() SET(CMAKE_C_FLAGS "${WERROR_FLAGS} ${CMAKE_C_FLAGS}") @@ -508,23 +519,26 @@ LIST(SORT LMMS_INCLUDES) # we somehow have to make LMMS-binary depend on MOC-files ADD_FILE_DEPENDENCIES("${CMAKE_BINARY_DIR}/lmmsconfig.h") -IF(WIN32) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") -ELSE(WIN32) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC") -ENDIF(WIN32) +#SET(CMAKE_POSITION_INDEPENDENT_CODE ON) +IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) + IF(WIN32) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") + ELSE(WIN32) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DPIC") + ENDIF(WIN32) +ENDIF() # use ccache OPTION(USE_CCACHE "Use ccache for compilation" OFF) IF(USE_CCACHE) - FIND_PROGRAM(CCACHE ccache) - IF (CCACHE) - MESSAGE(STATUS "Using ccache found in PATH") - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) - ELSE() - MESSAGE(WARNING "USE_CCACHE enabled, but no ccache found") - ENDIF() + FIND_PROGRAM(CCACHE ccache) + IF (CCACHE) + MESSAGE(STATUS "Using ccache found in PATH") + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) + ELSE() + MESSAGE(WARNING "USE_CCACHE enabled, but no ccache found") + ENDIF() ENDIF() # make sub-directories From 5d4bba9c3c942c8d6066ed1c655c8c227e5dc7d0 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 11:17:30 +0200 Subject: [PATCH 02/16] Port MicroTimer to portable C++11 for MSVC compatibility --- include/MicroTimer.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/MicroTimer.h b/include/MicroTimer.h index ff10020ece9..523b691e9e9 100644 --- a/include/MicroTimer.h +++ b/include/MicroTimer.h @@ -27,16 +27,19 @@ #include "lmmsconfig.h" -#ifdef LMMS_HAVE_SYS_TIME_H -#include -#endif - +#include #include #include "lmms_basics.h" class MicroTimer { + using clock = std::chrono::steady_clock; + using time_point = std::chrono::steady_clock::time_point; + + static_assert (std::ratio_less_equal::value, "MicroTimer: steady_clock doesn't support microsecond resolution"); + public: inline MicroTimer() { @@ -49,21 +52,18 @@ class MicroTimer inline void reset() { - gettimeofday( &begin, NULL ); + begin = clock::now(); } inline int elapsed() const { - struct timeval now; - gettimeofday( &now, NULL ); - return ( now.tv_sec - begin.tv_sec ) * 1000 * 1000 + - ( now.tv_usec - begin.tv_usec ); + auto now = clock::now(); + return std::chrono::duration_cast>(now - begin).count(); } private: - struct timeval begin; - + time_point begin; } ; From f123b82f27a5a1fc83e698dc4afa01fa925bcb9c Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 11:18:11 +0200 Subject: [PATCH 03/16] MSVC: Use Q_LIKELY and Q_UNLIKELY instead of gcc-specific extensions --- include/lmms_basics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/lmms_basics.h b/include/lmms_basics.h index 8fe4325b869..205d2efd2c4 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -56,8 +56,8 @@ typedef uint16_t fx_ch_t; // FX-channel (0 to MAX_EFFECT_CHANNEL) typedef uint32_t jo_id_t; // (unique) ID of a journalling object // use for improved branch prediction -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) +#define likely(x) Q_LIKELY(x) +#define unlikely(x) Q_UNLIKELY(x) template From d32b373d785a574b12bd9c20a6036a9c6f2974c3 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 14:49:34 +0200 Subject: [PATCH 04/16] MSVC: Fix 64bit detection --- cmake/modules/DetectMachine.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/DetectMachine.cmake b/cmake/modules/DetectMachine.cmake index 60c4a0953ce..850ee8052f3 100644 --- a/cmake/modules/DetectMachine.cmake +++ b/cmake/modules/DetectMachine.cmake @@ -16,6 +16,10 @@ MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") SET(LMMS_HOST_X86 FALSE) SET(LMMS_HOST_X86_64 FALSE) +IF(MSVC) + STRING(REGEX MATCH "86_64|amd64|AMD64" WIN64 "${CMAKE_SYSTEM_PROCESSOR}") +ENDIF() + IF(WIN32) IF(WIN64) SET(IS_X86_64 TRUE) From 8ed6295a7d23f667a788943254af8ef9480e112d Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 15:01:13 +0200 Subject: [PATCH 05/16] Use CMAKE_CXX_STANDARD as a portable way of setting C++11 Fixes MSVC warnings "unknown option -std=c++11" --- CMakeLists.txt | 3 ++- plugins/CMakeLists.txt | 2 +- plugins/GigPlayer/CMakeLists.txt | 2 +- plugins/LadspaEffect/CMakeLists.txt | 2 +- plugins/ReverbSC/CMakeLists.txt | 5 ----- plugins/opl2/CMakeLists.txt | 4 ---- plugins/papu/CMakeLists.txt | 2 +- plugins/zynaddsubfx/CMakeLists.txt | 5 ++--- src/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 2 +- 10 files changed, 11 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69083361e00..a3651f96f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0) PROJECT(lmms) @@ -109,6 +109,7 @@ IF(LMMS_BUILD_MSYS AND CMAKE_BUILD_TYPE STREQUAL "Debug") SET(STATUS_STK "not built as requested") ENDIF() +SET(CMAKE_CXX_STANDARD_REQUIRED ON) CHECK_INCLUDE_FILES(stdint.h LMMS_HAVE_STDINT_H) CHECK_INCLUDE_FILES(stdlib.h LMMS_HAVE_STDLIB_H) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ff807f354df..7c5b344811b 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,7 +2,7 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # Enable C++11 -ADD_DEFINITIONS(-std=c++0x) +SET(CMAKE_CXX_STANDARD 11) IF(LMMS_BUILD_APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/plugins/GigPlayer/CMakeLists.txt b/plugins/GigPlayer/CMakeLists.txt index 88e15f87bd1..05e9f529dbd 100644 --- a/plugins/GigPlayer/CMakeLists.txt +++ b/plugins/GigPlayer/CMakeLists.txt @@ -4,7 +4,7 @@ if(LMMS_HAVE_GIG) # Disable C++11 on Clang until gig.h is patched IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - REMOVE_DEFINITIONS(-std=c++0x) + SET(CMAKE_CXX_STANDARD 98) ENDIF() # Required for not crashing loading files with libgig diff --git a/plugins/LadspaEffect/CMakeLists.txt b/plugins/LadspaEffect/CMakeLists.txt index e827611402c..bd178a8c49d 100644 --- a/plugins/LadspaEffect/CMakeLists.txt +++ b/plugins/LadspaEffect/CMakeLists.txt @@ -1,7 +1,7 @@ INCLUDE(BuildPlugin) # Disable C++11 -REMOVE_DEFINITIONS(-std=c++0x) +SET(CMAKE_CXX_STANDARD 98) BUILD_PLUGIN(ladspaeffect LadspaEffect.cpp LadspaControls.cpp LadspaControlDialog.cpp LadspaSubPluginFeatures.cpp LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaSubPluginFeatures.h MOCFILES LadspaEffect.h LadspaControls.h LadspaControlDialog.h EMBEDDED_RESOURCES logo.png) diff --git a/plugins/ReverbSC/CMakeLists.txt b/plugins/ReverbSC/CMakeLists.txt index 71706df88ce..f6f6c7ee70f 100644 --- a/plugins/ReverbSC/CMakeLists.txt +++ b/plugins/ReverbSC/CMakeLists.txt @@ -1,10 +1,5 @@ INCLUDE(BuildPlugin) -# Enable C++11 for CXXFLAGS only -# This is needed since this plugin uses C. Otherwise Travis fails -REMOVE_DEFINITIONS(-std=c++0x) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - BUILD_PLUGIN( reverbsc ReverbSC.cpp diff --git a/plugins/opl2/CMakeLists.txt b/plugins/opl2/CMakeLists.txt index a62eee58809..c12530af8ec 100644 --- a/plugins/opl2/CMakeLists.txt +++ b/plugins/opl2/CMakeLists.txt @@ -1,7 +1,3 @@ INCLUDE(BuildPlugin) -# Enable C++11 for CXXFLAGS only -REMOVE_DEFINITIONS(-std=c++0x) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - BUILD_PLUGIN(OPL2 opl2instrument.cpp opl2instrument.h opl.h fmopl.c fmopl.h temuopl.cpp temuopl.h MOCFILES opl2instrument.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/papu/CMakeLists.txt b/plugins/papu/CMakeLists.txt index b45fcf61472..036ef19b5ef 100644 --- a/plugins/papu/CMakeLists.txt +++ b/plugins/papu/CMakeLists.txt @@ -1,6 +1,6 @@ INCLUDE(BuildPlugin) # Disable C++11 -REMOVE_DEFINITIONS(-std=c++0x) +SET(CMAKE_CXX_STANDARD 98) BUILD_PLUGIN(papu papu_instrument.cpp papu_instrument.h Basic_Gb_Apu.cpp Basic_Gb_Apu.h gb_apu/Gb_Oscs.cpp gb_apu/Gb_Apu.h gb_apu/Blip_Buffer.cpp gb_apu/Gb_Apu.cpp gb_apu/Gb_Oscs.h gb_apu/blargg_common.h gb_apu/Blip_Buffer.h gb_apu/Multi_Buffer.cpp gb_apu/blargg_source.h gb_apu/Multi_Buffer.h MOCFILES papu_instrument.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/zynaddsubfx/CMakeLists.txt b/plugins/zynaddsubfx/CMakeLists.txt index d0e810c0b4a..cacb2a5b9f9 100644 --- a/plugins/zynaddsubfx/CMakeLists.txt +++ b/plugins/zynaddsubfx/CMakeLists.txt @@ -24,9 +24,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-d IF(LMMS_BUILD_WIN32) # link system-libraries ADD_DEFINITIONS(-DPTW32_STATIC_LIB) - # fix X11 headers errors caused by bug with mingw + c++11 - REMOVE_DEFINITIONS(-std=c++0x) - ADD_DEFINITIONS(-std=gnu++0x) + # fix X11 headers errors caused by bug with mingw + c++11 (enable -std=gnu++0x) + SET(CMAKE_CXX_EXTENSIONS ON) ENDIF(LMMS_BUILD_WIN32) SET(FLTK_SKIP_OPENGL TRUE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 985f380529b..6b613d333af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,8 +7,8 @@ SET(LMMS_UIS "") SET(CMAKE_AUTOMOC ON) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -# Enable C++11 -ADD_DEFINITIONS(-std=c++0x) +# Enable C11 & C++11 +SET(CMAKE_CXX_STANDARD 11) IF(LMMS_BUILD_APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8cbe23858bf..bb846ea69d2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x") +SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_AUTOMOC ON) From c2af8ae5549e9229742f4543646eece64ff1129f Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 15:03:20 +0200 Subject: [PATCH 06/16] Remove "-fno-exceptions" compile flag --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3651f96f54..bfacedc901e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,7 +506,7 @@ IF(NOT CMAKE_BUILD_TYPE) ENDIF() SET(CMAKE_C_FLAGS "${WERROR_FLAGS} ${CMAKE_C_FLAGS}") -SET(CMAKE_CXX_FLAGS "-fno-exceptions ${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}") +SET(CMAKE_CXX_FLAGS "${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLMMS_DEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG") From 9ae1bdecda6dfcc68aa1acbd59ca094458696f3c Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 16 Oct 2017 15:51:21 +0200 Subject: [PATCH 07/16] MSVC compilation fixes --- include/BasicFilters.h | 2 +- include/RemotePlugin.h | 7 ++++--- include/TrackContainerView.h | 1 + include/lmms_basics.h | 5 ++++- src/CMakeLists.txt | 4 +++- src/core/DrumSynth.cpp | 5 +++++ src/core/InstrumentSoundShaping.cpp | 13 +++++++------ src/core/LocklessAllocator.cpp | 1 - src/core/Mixer.cpp | 2 +- src/core/MixerWorkerThread.cpp | 9 +++++++-- src/gui/dialogs/VersionedSaveDialog.cpp | 2 +- 11 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/BasicFilters.h b/include/BasicFilters.h index a3753dd9b3c..a0a1fc85da4 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -218,7 +218,7 @@ class OnePole }; typedef OnePole<2> StereoOnePole; -template +template class BasicFilters { MM_OPERATORS diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 2d811487587..bfba39de269 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -29,6 +29,7 @@ #include "MidiEvent.h" #include "VstSyncData.h" +#include #include #include #include @@ -234,7 +235,7 @@ class shmFifo // recursive lock inline void lock() { - if( !isInvalid() && __sync_add_and_fetch( &m_lockDepth, 1 ) == 1 ) + if( !isInvalid() && m_lockDepth.fetch_add( 1 ) == 0 ) { m_dataSem.acquire(); } @@ -243,7 +244,7 @@ class shmFifo // recursive unlock inline void unlock() { - if( __sync_sub_and_fetch( &m_lockDepth, 1) <= 0 ) + if( m_lockDepth.fetch_sub( 1 ) <= 1 ) { m_dataSem.release(); } @@ -404,7 +405,7 @@ class shmFifo shmData * m_data; QSystemSemaphore m_dataSem; QSystemSemaphore m_messageSem; - volatile int m_lockDepth; + std::atomic_int m_lockDepth; } ; #endif diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index 07e498df463..67575583b51 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -174,6 +174,7 @@ public slots: TrackContainerView* m_trackContainerView; } ; + friend class TrackContainerView::scrollArea; TrackContainer* m_tc; typedef QList trackViewList; diff --git a/include/lmms_basics.h b/include/lmms_basics.h index 205d2efd2c4..9b4bd6d55bf 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -31,7 +31,7 @@ #include "lmmsconfig.h" #ifdef LMMS_HAVE_STDINT_H -#include +#include #endif @@ -59,6 +59,9 @@ typedef uint32_t jo_id_t; // (unique) ID of a journalling object #define likely(x) Q_LIKELY(x) #define unlikely(x) Q_UNLIKELY(x) +// windows headers define "min" and "max" macros, breaking the methods bwloe +#undef min +#undef max template struct typeInfo diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b613d333af..4dd7c650541 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,9 @@ INCLUDE_DIRECTORIES( "${CMAKE_SOURCE_DIR}/include" ) -IF(WIN32) +IF(WIN32 AND MSVC) + SET(WINRC "${CMAKE_BINARY_DIR}/lmms.rc") +ELSEIF(WIN32) SET(WINRC "${CMAKE_BINARY_DIR}/lmmsrc.obj") ADD_CUSTOM_COMMAND(OUTPUT "${WINRC}" COMMAND "${WINDRES}" diff --git a/src/core/DrumSynth.cpp b/src/core/DrumSynth.cpp index fd0695557f4..3379f1aa7ec 100644 --- a/src/core/DrumSynth.cpp +++ b/src/core/DrumSynth.cpp @@ -35,6 +35,11 @@ #define powf pow #endif +#ifdef _MSC_VER +//not #if LMMS_BUILD_WIN32 because we have strncasecmp in mingw +#define strcasecmp _stricmp +#endif + using namespace std; diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index 22327ae8eed..58bbec639a9 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -22,6 +22,7 @@ * */ +#include #include #include "InstrumentSoundShaping.h" @@ -153,8 +154,8 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, if( m_filterEnabledModel.value() ) { - float cutBuffer [frames]; - float resBuffer [frames]; + QVarLengthArray cutBuffer(frames); + QVarLengthArray resBuffer(frames); int old_filter_cut = 0; int old_filter_res = 0; @@ -167,11 +168,11 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, if( m_envLfoParameters[Cut]->isUsed() ) { - m_envLfoParameters[Cut]->fillLevel( cutBuffer, envTotalFrames, envReleaseBegin, frames ); + m_envLfoParameters[Cut]->fillLevel( cutBuffer.data(), envTotalFrames, envReleaseBegin, frames ); } if( m_envLfoParameters[Resonance]->isUsed() ) { - m_envLfoParameters[Resonance]->fillLevel( resBuffer, envTotalFrames, envReleaseBegin, frames ); + m_envLfoParameters[Resonance]->fillLevel( resBuffer.data(), envTotalFrames, envReleaseBegin, frames ); } const float fcv = m_filterCutModel.value(); @@ -246,8 +247,8 @@ void InstrumentSoundShaping::processAudioBuffer( sampleFrame* buffer, if( m_envLfoParameters[Volume]->isUsed() ) { - float volBuffer [frames]; - m_envLfoParameters[Volume]->fillLevel( volBuffer, envTotalFrames, envReleaseBegin, frames ); + QVarLengthArray volBuffer(frames); + m_envLfoParameters[Volume]->fillLevel( volBuffer.data(), envTotalFrames, envReleaseBegin, frames ); for( fpp_t frame = 0; frame < frames; ++frame ) { diff --git a/src/core/LocklessAllocator.cpp b/src/core/LocklessAllocator.cpp index 8a7a2fb546c..3a582fc76b7 100644 --- a/src/core/LocklessAllocator.cpp +++ b/src/core/LocklessAllocator.cpp @@ -25,7 +25,6 @@ #include "LocklessAllocator.h" #include -#include #include "lmmsconfig.h" diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 53cacbe6386..8948810f0af 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -63,7 +63,7 @@ typedef LocklessList::Element LocklessListElement; -static __thread bool s_renderingThread; +static thread_local bool s_renderingThread; diff --git a/src/core/MixerWorkerThread.cpp b/src/core/MixerWorkerThread.cpp index dfcc1ff6a51..2f3b46959a0 100644 --- a/src/core/MixerWorkerThread.cpp +++ b/src/core/MixerWorkerThread.cpp @@ -34,6 +34,11 @@ MixerWorkerThread::JobQueue MixerWorkerThread::globalJobQueue; QWaitCondition * MixerWorkerThread::queueReadyWaitCond = NULL; QList MixerWorkerThread::workerThreads; +#ifdef _MSC_VER + #define ASM(x) __asm { x }; +#else + #define ASM(x) asm ( "x" ); +#endif // implementation of internal JobQueue @@ -88,8 +93,8 @@ void MixerWorkerThread::JobQueue::wait() { while( (int) m_itemsDone < (int) m_queueSize ) { -#if defined(LMMS_HOST_X86) || defined(LMMS_HOST_X86_64) - asm( "pause" ); +#if defined(LMMS_HOST_X86) || (defined(LMMS_HOST_X86_64) && ! defined(_MSC_VER) ) + ASM( "pause" ); #endif } } diff --git a/src/gui/dialogs/VersionedSaveDialog.cpp b/src/gui/dialogs/VersionedSaveDialog.cpp index e2720e5a122..e2acff590c4 100644 --- a/src/gui/dialogs/VersionedSaveDialog.cpp +++ b/src/gui/dialogs/VersionedSaveDialog.cpp @@ -98,7 +98,7 @@ bool VersionedSaveDialog::changeFileNameVersion(QString &fileName, bool incremen Q_ASSERT( ok ); // Can't decrement 0 - if ( !increment and version == 0 ) + if ( !increment && version == 0 ) return false; // Replace version number version = increment ? version + 1 : version - 1; From ba2ed12f05df667db940dbc679e89f04643a87d7 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 11:01:21 +0100 Subject: [PATCH 08/16] MSVC: EXPORT macro fixes --- include/Controller.h | 3 ++- include/PlayHandle.h | 4 +++- include/export.h | 7 ++++--- plugins/Amplifier/Amplifier.cpp | 2 +- plugins/BassBooster/BassBooster.cpp | 2 +- plugins/Bitcrush/Bitcrush.cpp | 2 +- plugins/CrossoverEQ/CrossoverEQ.cpp | 2 +- plugins/Delay/DelayEffect.cpp | 2 +- plugins/DualFilter/DualFilter.cpp | 2 +- plugins/Eq/EqEffect.cpp | 2 +- plugins/Flanger/FlangerEffect.cpp | 2 +- plugins/HydrogenImport/HydrogenImport.cpp | 2 +- plugins/LadspaEffect/LadspaEffect.cpp | 2 +- plugins/MidiExport/MidiExport.cpp | 2 +- plugins/MidiImport/MidiImport.cpp | 2 +- plugins/MultitapEcho/MultitapEcho.cpp | 2 +- plugins/ReverbSC/ReverbSC.cpp | 2 +- plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp | 2 +- plugins/VstEffect/VstEffect.cpp | 2 +- plugins/audio_file_processor/audio_file_processor.cpp | 2 +- plugins/bit_invader/bit_invader.cpp | 2 +- plugins/dynamics_processor/dynamics_processor.cpp | 2 +- plugins/kicker/kicker.cpp | 2 +- plugins/ladspa_browser/ladspa_browser.cpp | 2 +- plugins/lb302/lb302.cpp | 2 +- plugins/monstro/Monstro.cpp | 2 +- plugins/nes/Nes.cpp | 2 +- plugins/opl2/opl2instrument.cpp | 2 +- plugins/organic/organic.cpp | 2 +- plugins/papu/papu_instrument.cpp | 2 +- plugins/patman/patman.cpp | 2 +- plugins/peak_controller_effect/peak_controller_effect.cpp | 2 +- plugins/sfxr/sfxr.cpp | 2 +- plugins/sid/sid_instrument.cpp | 2 +- plugins/stereo_enhancer/stereo_enhancer.cpp | 2 +- plugins/stereo_matrix/stereo_matrix.cpp | 2 +- plugins/triple_oscillator/TripleOscillator.cpp | 2 +- plugins/vestige/vestige.cpp | 2 +- plugins/vibed/vibed.cpp | 2 +- plugins/watsyn/Watsyn.cpp | 2 +- plugins/waveshaper/waveshaper.cpp | 2 +- plugins/xpressive/expressive_plugin.cpp | 2 +- plugins/zynaddsubfx/ZynAddSubFx.cpp | 2 +- 43 files changed, 49 insertions(+), 45 deletions(-) diff --git a/include/Controller.h b/include/Controller.h index 3a9946073af..7aded3bc1ee 100644 --- a/include/Controller.h +++ b/include/Controller.h @@ -27,6 +27,7 @@ #ifndef CONTROLLER_H #define CONTROLLER_H +#include "export.h" #include "Engine.h" #include "Model.h" #include "JournallingObject.h" @@ -40,7 +41,7 @@ class ControllerConnection; typedef QVector ControllerVector; -class Controller : public Model, public JournallingObject +class EXPORT Controller : public Model, public JournallingObject { Q_OBJECT public: diff --git a/include/PlayHandle.h b/include/PlayHandle.h index 329a8f7667e..a1c8e5c33da 100644 --- a/include/PlayHandle.h +++ b/include/PlayHandle.h @@ -28,6 +28,8 @@ #include #include +#include "export.h" + #include "MemoryManager.h" #include "ThreadableJob.h" @@ -38,7 +40,7 @@ class QThread; class Track; class AudioPort; -class PlayHandle : public ThreadableJob +class EXPORT PlayHandle : public ThreadableJob { public: enum Types diff --git a/include/export.h b/include/export.h index 5b64d8d0869..80d6b7452ac 100644 --- a/include/export.h +++ b/include/export.h @@ -22,6 +22,7 @@ * */ +#include #ifndef EXPORT_H #define EXPORT_H @@ -31,10 +32,10 @@ #ifdef LMMS_BUILD_WIN32 #ifdef PLUGIN_NAME -#define EXPORT __declspec(dllimport) -#define PLUGIN_EXPORT __declspec(dllexport) +#define EXPORT Q_DECL_IMPORT +#define PLUGIN_EXPORT Q_DECL_EXPORT #else -#define EXPORT __declspec(dllexport) +#define EXPORT Q_DECL_EXPORT #endif #else diff --git a/plugins/Amplifier/Amplifier.cpp b/plugins/Amplifier/Amplifier.cpp index f7b23d87fe9..c11fa6bcc1c 100644 --- a/plugins/Amplifier/Amplifier.cpp +++ b/plugins/Amplifier/Amplifier.cpp @@ -138,7 +138,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new AmplifierEffect( parent, static_cast( data ) ); } diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index 0499ba7ee0a..f7387b46eaa 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -148,7 +148,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new BassBoosterEffect( parent, static_cast( data ) ); } diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 6c7073f3100..918b8efdde5 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -244,7 +244,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new BitcrushEffect( parent, static_cast( data ) ); } diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index b406045878e..3dc0e826574 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -215,7 +215,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new CrossoverEQEffect( parent, static_cast( data ) ); } diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 2305b19668a..0161178b83c 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -157,7 +157,7 @@ extern "C" { //needed for getting plugin out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new DelayEffect( parent , static_cast( data ) ); } diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index 3189e2c2bdb..94450cc6ff7 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -222,7 +222,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new DualFilterEffect( parent, static_cast( data ) ); } diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index fa664aa3b2d..4a10b672e4d 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -418,7 +418,7 @@ extern "C" { //needed for getting plugin out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new EqEffect( parent , static_cast( data ) ); } diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index d270c080182..2f5d96ef508 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -143,7 +143,7 @@ extern "C" { //needed for getting plugin out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new FlangerEffect( parent , static_cast( data ) ); } diff --git a/plugins/HydrogenImport/HydrogenImport.cpp b/plugins/HydrogenImport/HydrogenImport.cpp index f86cdffd703..c7536e87ec7 100644 --- a/plugins/HydrogenImport/HydrogenImport.cpp +++ b/plugins/HydrogenImport/HydrogenImport.cpp @@ -340,7 +340,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new HydrogenImport( QString::fromUtf8( static_cast( _data ) ) ); diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index b5bbe2728c0..d24574ff916 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -593,7 +593,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return new LadspaEffect( _parent, static_cast( diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index 1e20e9d40f4..d691c483003 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -347,7 +347,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new MidiExport(); } diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 85d244ca589..729c8b20084 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -611,7 +611,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new MidiImport( QString::fromUtf8( static_cast( _data ) ) ); diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 7e84a289ef5..be46a50c6b6 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -164,7 +164,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new MultitapEchoEffect( parent, static_cast( data ) ); } diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index 58cb0a7703d..bfbd0390a96 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -151,7 +151,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new ReverbSCEffect( parent, diff --git a/plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp b/plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp index bba33463590..f07fa7f45b0 100644 --- a/plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp +++ b/plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp @@ -163,7 +163,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { return new SpectrumAnalyzer( parent, static_cast( data ) ); } diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index fb7b6b33ddd..17d29608b11 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -171,7 +171,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return new VstEffect( _parent, static_cast( diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index f7ce90e133f..278e681949c 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -1319,7 +1319,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new audioFileProcessor( static_cast( _data ) ); diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index 7f22211b2fd..3f95f02356a 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -582,7 +582,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new bitInvader( static_cast( _data ) ) ); } diff --git a/plugins/dynamics_processor/dynamics_processor.cpp b/plugins/dynamics_processor/dynamics_processor.cpp index 4f9c9648c72..12ed1fa88dd 100644 --- a/plugins/dynamics_processor/dynamics_processor.cpp +++ b/plugins/dynamics_processor/dynamics_processor.cpp @@ -233,7 +233,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return( new dynProcEffect( _parent, static_cast( diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 3b6b18c73b6..50af8628beb 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -367,7 +367,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new kickerInstrument( static_cast( _data ) ); } diff --git a/plugins/ladspa_browser/ladspa_browser.cpp b/plugins/ladspa_browser/ladspa_browser.cpp index 23134048c1e..cfc356c8615 100644 --- a/plugins/ladspa_browser/ladspa_browser.cpp +++ b/plugins/ladspa_browser/ladspa_browser.cpp @@ -61,7 +61,7 @@ Plugin::Descriptor PLUGIN_EXPORT ladspabrowser_plugin_descriptor = // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return new ladspaBrowser; } diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index 1a32f7f92d0..f3728b2025f 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -1041,7 +1041,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new lb302Synth( diff --git a/plugins/monstro/Monstro.cpp b/plugins/monstro/Monstro.cpp index 0ac0079f88d..badb4845d76 100644 --- a/plugins/monstro/Monstro.cpp +++ b/plugins/monstro/Monstro.cpp @@ -1963,7 +1963,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new MonstroInstrument( static_cast( _data ) ); } diff --git a/plugins/nes/Nes.cpp b/plugins/nes/Nes.cpp index b09f84a222d..ead8846873f 100644 --- a/plugins/nes/Nes.cpp +++ b/plugins/nes/Nes.cpp @@ -917,7 +917,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new NesInstrument( static_cast( _data ) ) ); } diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index 53c4fb08418..fc429820e4d 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -77,7 +77,7 @@ Plugin::Descriptor PLUGIN_EXPORT OPL2_plugin_descriptor = }; // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new opl2instrument( static_cast( _data ) ) ); } diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index 7d7c60057c3..49edc0c3011 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -641,7 +641,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new organicInstrument( static_cast( _data ) ) ); } diff --git a/plugins/papu/papu_instrument.cpp b/plugins/papu/papu_instrument.cpp index 3d4dfcf5d8d..e9b838f51fa 100644 --- a/plugins/papu/papu_instrument.cpp +++ b/plugins/papu/papu_instrument.cpp @@ -738,7 +738,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new papuInstrument( static_cast( _data ) ) ); diff --git a/plugins/patman/patman.cpp b/plugins/patman/patman.cpp index 55e64fa4805..2a15303bb46 100644 --- a/plugins/patman/patman.cpp +++ b/plugins/patman/patman.cpp @@ -66,7 +66,7 @@ Plugin::Descriptor PLUGIN_EXPORT patman_plugin_descriptor = // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new patmanInstrument( static_cast( _data ) ); } diff --git a/plugins/peak_controller_effect/peak_controller_effect.cpp b/plugins/peak_controller_effect/peak_controller_effect.cpp index ec4ec1e94c0..e08abcb2404 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect.cpp @@ -148,7 +148,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return new PeakControllerEffect( _parent, static_cast( _data ) ); diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index c8370de8200..c19c8730833 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -1119,7 +1119,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model*, void* data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model*, void* data ) { return new sfxrInstrument( static_cast( data ) ); } diff --git a/plugins/sid/sid_instrument.cpp b/plugins/sid/sid_instrument.cpp index 0ab8e217be1..796a1422183 100644 --- a/plugins/sid/sid_instrument.cpp +++ b/plugins/sid/sid_instrument.cpp @@ -822,7 +822,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new sidInstrument( static_cast( _data ) ) ); diff --git a/plugins/stereo_enhancer/stereo_enhancer.cpp b/plugins/stereo_enhancer/stereo_enhancer.cpp index 7d252f57654..cb55213f133 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.cpp +++ b/plugins/stereo_enhancer/stereo_enhancer.cpp @@ -163,7 +163,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return( new stereoEnhancerEffect( _parent, static_cast( diff --git a/plugins/stereo_matrix/stereo_matrix.cpp b/plugins/stereo_matrix/stereo_matrix.cpp index a9d2a8e10a5..b2634e95c29 100644 --- a/plugins/stereo_matrix/stereo_matrix.cpp +++ b/plugins/stereo_matrix/stereo_matrix.cpp @@ -113,7 +113,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return( new stereoMatrixEffect( _parent, static_cast( diff --git a/plugins/triple_oscillator/TripleOscillator.cpp b/plugins/triple_oscillator/TripleOscillator.cpp index 4efb040d220..0b7ff6bbe64 100644 --- a/plugins/triple_oscillator/TripleOscillator.cpp +++ b/plugins/triple_oscillator/TripleOscillator.cpp @@ -791,7 +791,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new TripleOscillator( static_cast( _data ) ); } diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index ec87e87808e..a3c3c66c8e4 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -1141,7 +1141,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new vestigeInstrument( static_cast( _data ) ); } diff --git a/plugins/vibed/vibed.cpp b/plugins/vibed/vibed.cpp index b3738ef2409..3442d39dba1 100644 --- a/plugins/vibed/vibed.cpp +++ b/plugins/vibed/vibed.cpp @@ -777,7 +777,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new vibed( static_cast( _data ) ) ); } diff --git a/plugins/watsyn/Watsyn.cpp b/plugins/watsyn/Watsyn.cpp index 40d64a4c437..c35ee7d81b2 100644 --- a/plugins/watsyn/Watsyn.cpp +++ b/plugins/watsyn/Watsyn.cpp @@ -1278,7 +1278,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return( new WatsynInstrument( static_cast( _data ) ) ); } diff --git a/plugins/waveshaper/waveshaper.cpp b/plugins/waveshaper/waveshaper.cpp index 0d6c1302965..047cd05d193 100644 --- a/plugins/waveshaper/waveshaper.cpp +++ b/plugins/waveshaper/waveshaper.cpp @@ -161,7 +161,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) { return( new waveShaperEffect( _parent, static_cast( diff --git a/plugins/xpressive/expressive_plugin.cpp b/plugins/xpressive/expressive_plugin.cpp index 75d22fc1e82..818ed74500e 100644 --- a/plugins/xpressive/expressive_plugin.cpp +++ b/plugins/xpressive/expressive_plugin.cpp @@ -877,7 +877,7 @@ __attribute__((destructor)) static void module_destroy() extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main(Model *, void * _data) { +PLUGIN_EXPORT Plugin * lmms_plugin_main(Model *, void * _data) { return (new Expressive(static_cast(_data))); } diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 275f0952d75..e6391b81219 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -658,7 +658,7 @@ extern "C" { // necessary for getting instance out of shared lib -Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) +PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) { return new ZynAddSubFxInstrument( static_cast( _data ) ); From 3d2062392d49e9106b866c9977845b5d837e9f3a Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 11:43:34 +0100 Subject: [PATCH 09/16] MSVC: Blacklist unsupported plugins --- plugins/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7c5b344811b..0820bb81317 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -86,6 +86,24 @@ IF("${PLUGIN_LIST}" STREQUAL "") ENDIF("${PLUGIN_LIST}" STREQUAL "") +IF(MSVC) + SET(MSVC_INCOMPATIBLE_PLUGINS + LadspaEffect + monstro + organic + ReverbSC + sid + vestige + vibed + vst_base + VstEffect + xpressive + zynaddsubfx + ) + message(WARNING "Compiling with MSVC. The following plugins are not available: ${MSVC_INCOMPATIBLE_PLUGINS}") + LIST(REMOVE_ITEM PLUGIN_LIST ${MSVC_INCOMPATIBLE_PLUGINS}) +ENDIF() + FOREACH(PLUGIN ${PLUGIN_LIST}) ADD_SUBDIRECTORY(${PLUGIN}) ENDFOREACH() From 6224e5ed6bef061fad0ca4fd71672c20a551999b Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 13:49:57 +0100 Subject: [PATCH 10/16] MSVC: Various fixes * CMake * Compiler flags fixes * Don't strip * Fix default template argument errors * Fix VLAs. MSVC doesn't support C99, so Variable-Length-Arrays are not available. Use QVarLengthArray instead. --- CMakeLists.txt | 4 +++- cmake/modules/BuildPlugin.cmake | 4 ++-- include/lmms_basics.h | 2 +- plugins/DualFilter/DualFilterControls.cpp | 4 ++-- plugins/LadspaEffect/LadspaEffect.cpp | 5 +++-- plugins/MultitapEcho/MultitapEchoControls.cpp | 4 ++-- plugins/xpressive/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 8 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfacedc901e..b27c52da58d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,7 +489,9 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) IF (CMAKE_COMPILER_IS_GNUCXX AND ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.8.0") OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8.0") OR LMMS_BUILD_WIN32)) SET(WERROR_FLAGS "${WERROR_FLAGS} -Wno-array-bounds") ENDIF() -ELSE() +ELSEIF(MSVC) + # Remove any existing /W flags + STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) SET(WERROR_FLAGS "/W2") IF(${USE_WERROR}) SET(WERROR_FLAGS "${WERROR_FLAGS} /WX") diff --git a/cmake/modules/BuildPlugin.cmake b/cmake/modules/BuildPlugin.cmake index f3bea9e3147..586279e82d8 100644 --- a/cmake/modules/BuildPlugin.cmake +++ b/cmake/modules/BuildPlugin.cmake @@ -74,10 +74,10 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader ${CMAKE_BINARY_DIR}/lmms") ADD_DEPENDENCIES(${PLUGIN_NAME} lmms) ENDIF(LMMS_BUILD_APPLE) - IF(LMMS_BUILD_WIN32) + IF(LMMS_BUILD_WIN32 AND STRIP) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} $) - ENDIF(LMMS_BUILD_WIN32) + ENDIF() SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${RCC_OUT} ${plugin_MOC_out}") ENDMACRO(BUILD_PLUGIN) diff --git a/include/lmms_basics.h b/include/lmms_basics.h index 9b4bd6d55bf..637867b4d34 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -96,7 +96,7 @@ struct typeInfo template<> inline float typeInfo::minEps() { - return 1.0e-10; + return 1.0e-10f; } template<> diff --git a/plugins/DualFilter/DualFilterControls.cpp b/plugins/DualFilter/DualFilterControls.cpp index 7fdd59e88c1..63f7887f19f 100644 --- a/plugins/DualFilter/DualFilterControls.cpp +++ b/plugins/DualFilter/DualFilterControls.cpp @@ -40,7 +40,7 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : m_enabled1Model( true, this, tr( "Filter 1 enabled" ) ), m_filter1Model( this, tr( "Filter 1 type" ) ), m_cut1Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff 1 frequency" ) ), - m_res1Model( 0.5, BasicFilters<0>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 1" ) ), + m_res1Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 1" ) ), m_gain1Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 1" ) ), m_mixModel( 0.0f, -1.0f, 1.0f, 0.01f, this, tr( "Mix" ) ), @@ -48,7 +48,7 @@ DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : m_enabled2Model( true, this, tr( "Filter 2 enabled" ) ), m_filter2Model( this, tr( "Filter 2 type" ) ), m_cut2Model( 7000.0f, 1.0f, 20000.0f, 1.0f, this, tr( "Cutoff 2 frequency" ) ), - m_res2Model( 0.5, BasicFilters<0>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 2" ) ), + m_res2Model( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance 2" ) ), m_gain2Model( 100.0f, 0.0f, 200.0f, 0.1f, this, tr( "Gain 2" ) ) { m_filter1Model.addItem( tr( "LowPass" ), new PixmapLoader( "filter_lp" ) ); diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index d24574ff916..0ce66721322 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -24,6 +24,7 @@ */ +#include #include #include "LadspaEffect.h" @@ -141,12 +142,12 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, int frames = _frames; sampleFrame * o_buf = NULL; - sampleFrame sBuf [_frames]; + QVarLengthArray sBuf(_frames * DEFAULT_CHANNELS); if( m_maxSampleRate < Engine::mixer()->processingSampleRate() ) { o_buf = _buf; - _buf = &sBuf[0]; + _buf = reinterpret_cast(sBuf.data()); sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / Engine::mixer()->processingSampleRate(); diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 09c45228d72..899d3e80f56 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -102,7 +102,7 @@ void MultitapEchoControls::setDefaultAmpShape() { const int length = m_steps.value(); - float samples [length]; + QVarLengthArray samples(length); for( int i = 0; i < length; ++i ) { samples[i] = 0.0f; @@ -116,7 +116,7 @@ void MultitapEchoControls::setDefaultLpShape() { const int length = m_steps.value(); - float samples [length]; + QVarLengthArray samples(length); for( int i = 0; i < length; ++i ) { samples[i] = 3.0f; diff --git a/plugins/xpressive/CMakeLists.txt b/plugins/xpressive/CMakeLists.txt index 68cb0a02b88..a9de4646eb2 100644 --- a/plugins/xpressive/CMakeLists.txt +++ b/plugins/xpressive/CMakeLists.txt @@ -2,7 +2,7 @@ INCLUDE(BuildPlugin) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_sc_andor -Dexprtk_disable_return_statement -Dexprtk_disable_break_continue -Dexprtk_disable_comments -Dexprtk_disable_string_capabilities -Dexprtk_disable_rtl_io_file -Dexprtk_disable_rtl_vecops ${WERROR_FLAGS} -fexceptions") -IF(WIN32) +IF(WIN32 AND NOT MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj -Dexprtk_disable_enhanced_features") ENDIF() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4dd7c650541..07820518901 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,7 +118,7 @@ ENDIF() SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LMMS_RCC_OUT} ${LMMS_UI_OUT} lmmsconfig.h lmms.1.gz") IF(LMMS_BUILD_WIN32) - SET(EXTRA_LIBRARIES "-lwinmm") + SET(EXTRA_LIBRARIES "winmm") ENDIF() IF(LMMS_BUILD_APPLE) From 95c0538d1cd963462ec16cec5afef0d33e55580f Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 13:52:31 +0100 Subject: [PATCH 11/16] MSVC: Fix plugins not loading with debug builds The "d" suffix used in debug builds breaks plugin loading because LMMS expects to find a descriptor named e.g. "kickerd_plugin_descriptor" instead of "kicker_plugin_descriptor" when discovering a plugin with the filename "kickerd.dll". --- plugins/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 0820bb81317..fb8f8bee7fb 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,5 +1,6 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +SET(CMAKE_DEBUG_POSTFIX "") # Enable C++11 SET(CMAKE_CXX_STANDARD 11) From 313d43bc162cf4c68188cfd57d7b6c1ae79bf4a1 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 13:54:19 +0100 Subject: [PATCH 12/16] MSVC: Show compiler version in AboutDialog Make AboutDialog support MSVC compiler info so we can use a screenshot of it to brag with on #devtalk --- include/versioninfo.h | 8 ++++++-- src/core/main.cpp | 2 +- src/gui/AboutDialog.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/versioninfo.h b/include/versioninfo.h index 8477a61c0d7..b34936d5742 100644 --- a/include/versioninfo.h +++ b/include/versioninfo.h @@ -1,7 +1,11 @@ +#include "lmms_basics.h" + #ifdef __GNUC__ -#define GCC_VERSION "GCC " __VERSION__ +#define COMPILER_VERSION "GCC " __VERSION__ +#elif defined(_MSC_VER) +#define COMPILER_VERSION "MSVC " STRINGIFY(_MSC_FULL_VER) #else -#define GCC_VERSION "unknown compiler" +#define COMPILER_VERSION "unknown compiler" #endif #ifdef LMMS_HOST_X86 diff --git a/src/core/main.cpp b/src/core/main.cpp index dab9d445a53..78e282a146f 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -130,7 +130,7 @@ void printVersion( char *executableName ) "License as published by the Free Software Foundation; either\n" "version 2 of the License, or (at your option) any later version.\n\n" "Try \"%s --help\" for more information.\n\n", LMMS_VERSION, - PLATFORM, MACHINE, QT_VERSION_STR, GCC_VERSION, + PLATFORM, MACHINE, QT_VERSION_STR, COMPILER_VERSION, LMMS_PROJECT_COPYRIGHT, executableName ); } diff --git a/src/gui/AboutDialog.cpp b/src/gui/AboutDialog.cpp index 618d35966a8..11672e6a269 100644 --- a/src/gui/AboutDialog.cpp +++ b/src/gui/AboutDialog.cpp @@ -44,7 +44,7 @@ AboutDialog::AboutDialog(QWidget* parent) : arg( PLATFORM ). arg( MACHINE ). arg( QT_VERSION_STR ). - arg( GCC_VERSION ) ); + arg( COMPILER_VERSION ) ); versionLabel->setTextInteractionFlags( versionLabel->textInteractionFlags() | Qt::TextSelectableByMouse ); From 852708863a62afeaa577ae425872345002eb7d03 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 16:09:55 +0100 Subject: [PATCH 13/16] Fix Linux compilation issues caused by MSVC fixes --- CMakeLists.txt | 8 ++------ include/BasicFilters.h | 4 ++-- include/NotePlayHandle.h | 2 +- include/export.h | 8 +++----- plugins/LadspaEffect/CMakeLists.txt | 6 +++--- plugins/MultitapEcho/MultitapEchoControls.cpp | 1 + plugins/papu/CMakeLists.txt | 3 --- plugins/vst_base/CMakeLists.txt | 1 + plugins/zynaddsubfx/CMakeLists.txt | 1 + src/core/LocklessAllocator.cpp | 4 ++++ src/core/MixerWorkerThread.cpp | 11 ++--------- 11 files changed, 20 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b27c52da58d..5e32368b2f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -471,14 +471,11 @@ ELSE() SET (STATUS_DEBUG_FPE "Disabled") ENDIF(WANT_DEBUG_FPE) - # check for libsamplerate PKG_CHECK_MODULES(SAMPLERATE REQUIRED samplerate>=0.1.8) - -message("Compiler: ${CMAKE_CXX_COMPILER_ID} Is MSVC: ${MSVC} Version: ${MSVC}") # set compiler flags -IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|AppleClang") SET(WERROR_FLAGS "-Wall -Werror=unused-function -Wno-sign-compare -Wno-strict-overflow") OPTION(USE_WERROR "Add -werror to the build flags. Stops the build on warnings" OFF) IF(${USE_WERROR}) @@ -522,8 +519,7 @@ LIST(SORT LMMS_INCLUDES) # we somehow have to make LMMS-binary depend on MOC-files ADD_FILE_DEPENDENCIES("${CMAKE_BINARY_DIR}/lmmsconfig.h") -#SET(CMAKE_POSITION_INDEPENDENT_CODE ON) -IF(CMAKE_CXX_COMPILER_ID MATCHES (GNU|AppleClang)) +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|AppleClang") IF(WIN32) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") ELSE(WIN32) diff --git a/include/BasicFilters.h b/include/BasicFilters.h index a0a1fc85da4..684596c4d7e 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -44,7 +44,7 @@ #include "interpolation.h" #include "MemoryManager.h" -template class BasicFilters; +template class BasicFilters; template class LinkwitzRiley @@ -218,7 +218,7 @@ class OnePole }; typedef OnePole<2> StereoOnePole; -template +template class BasicFilters { MM_OPERATORS diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 344980eb61e..86d10df7147 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -27,6 +27,7 @@ #define NOTE_PLAY_HANDLE_H #include "AtomicInt.h" +#include "BasicFilters.h" #include "Note.h" #include "PlayHandle.h" #include "Track.h" @@ -36,7 +37,6 @@ class QReadWriteLock; class InstrumentTrack; class NotePlayHandle; -template class BasicFilters; typedef QList NotePlayHandleList; typedef QList ConstNotePlayHandleList; diff --git a/include/export.h b/include/export.h index 80d6b7452ac..dd3709704f3 100644 --- a/include/export.h +++ b/include/export.h @@ -22,8 +22,6 @@ * */ -#include - #ifndef EXPORT_H #define EXPORT_H @@ -32,10 +30,10 @@ #ifdef LMMS_BUILD_WIN32 #ifdef PLUGIN_NAME -#define EXPORT Q_DECL_IMPORT -#define PLUGIN_EXPORT Q_DECL_EXPORT +#define EXPORT __declspec(dllimport) +#define PLUGIN_EXPORT __declspec(dllexport) #else -#define EXPORT Q_DECL_EXPORT +#define EXPORT __declspec(dllexport) #endif #else diff --git a/plugins/LadspaEffect/CMakeLists.txt b/plugins/LadspaEffect/CMakeLists.txt index bd178a8c49d..25ea5c4c859 100644 --- a/plugins/LadspaEffect/CMakeLists.txt +++ b/plugins/LadspaEffect/CMakeLists.txt @@ -1,12 +1,12 @@ INCLUDE(BuildPlugin) -# Disable C++11 -SET(CMAKE_CXX_STANDARD 98) - BUILD_PLUGIN(ladspaeffect LadspaEffect.cpp LadspaControls.cpp LadspaControlDialog.cpp LadspaSubPluginFeatures.cpp LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaSubPluginFeatures.h MOCFILES LadspaEffect.h LadspaControls.h LadspaControlDialog.h EMBEDDED_RESOURCES logo.png) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ladspa") +# Disable C++11 +SET(CMAKE_CXX_STANDARD 98) + IF(WANT_CAPS) ADD_SUBDIRECTORY(caps) ENDIF(WANT_CAPS) diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 899d3e80f56..533f5c30e5e 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -24,6 +24,7 @@ */ #include +#include #include "MultitapEchoControls.h" #include "MultitapEcho.h" diff --git a/plugins/papu/CMakeLists.txt b/plugins/papu/CMakeLists.txt index 036ef19b5ef..20d9bbd2033 100644 --- a/plugins/papu/CMakeLists.txt +++ b/plugins/papu/CMakeLists.txt @@ -1,6 +1,3 @@ INCLUDE(BuildPlugin) -# Disable C++11 -SET(CMAKE_CXX_STANDARD 98) - BUILD_PLUGIN(papu papu_instrument.cpp papu_instrument.h Basic_Gb_Apu.cpp Basic_Gb_Apu.h gb_apu/Gb_Oscs.cpp gb_apu/Gb_Apu.h gb_apu/Blip_Buffer.cpp gb_apu/Gb_Apu.cpp gb_apu/Gb_Oscs.h gb_apu/blargg_common.h gb_apu/Blip_Buffer.h gb_apu/Multi_Buffer.cpp gb_apu/blargg_source.h gb_apu/Multi_Buffer.h MOCFILES papu_instrument.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/vst_base/CMakeLists.txt b/plugins/vst_base/CMakeLists.txt index f92bb916ea8..5abd1c832b1 100644 --- a/plugins/vst_base/CMakeLists.txt +++ b/plugins/vst_base/CMakeLists.txt @@ -71,6 +71,7 @@ ADD_CUSTOM_COMMAND( -L${WINE_LIBRARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/RemoteVstPlugin.cpp -ansi -mwindows -lpthread ${EXTRA_FLAGS} -fno-omit-frame-pointer + -std=c++0x ${WINE_BUILD_FLAGS} -o ../RemoteVstPlugin # Ensure correct file extension diff --git a/plugins/zynaddsubfx/CMakeLists.txt b/plugins/zynaddsubfx/CMakeLists.txt index cacb2a5b9f9..bc711123cef 100644 --- a/plugins/zynaddsubfx/CMakeLists.txt +++ b/plugins/zynaddsubfx/CMakeLists.txt @@ -1,5 +1,6 @@ INCLUDE(BuildPlugin) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # definitions for ZynAddSubFX IF(LMMS_BUILD_LINUX OR LMMS_BUILD_APPLE OR LMMS_BUILD_OPENBSD) diff --git a/src/core/LocklessAllocator.cpp b/src/core/LocklessAllocator.cpp index 3a582fc76b7..3e8d3a7fd88 100644 --- a/src/core/LocklessAllocator.cpp +++ b/src/core/LocklessAllocator.cpp @@ -26,6 +26,10 @@ #include +#ifndef LMMS_BUILD_WIN32 +#include +#endif + #include "lmmsconfig.h" diff --git a/src/core/MixerWorkerThread.cpp b/src/core/MixerWorkerThread.cpp index 2f3b46959a0..e31d8b48895 100644 --- a/src/core/MixerWorkerThread.cpp +++ b/src/core/MixerWorkerThread.cpp @@ -34,13 +34,6 @@ MixerWorkerThread::JobQueue MixerWorkerThread::globalJobQueue; QWaitCondition * MixerWorkerThread::queueReadyWaitCond = NULL; QList MixerWorkerThread::workerThreads; -#ifdef _MSC_VER - #define ASM(x) __asm { x }; -#else - #define ASM(x) asm ( "x" ); -#endif - - // implementation of internal JobQueue void MixerWorkerThread::JobQueue::reset( OperationMode _opMode ) { @@ -93,8 +86,8 @@ void MixerWorkerThread::JobQueue::wait() { while( (int) m_itemsDone < (int) m_queueSize ) { -#if defined(LMMS_HOST_X86) || (defined(LMMS_HOST_X86_64) && ! defined(_MSC_VER) ) - ASM( "pause" ); +#if defined(LMMS_HOST_X86) || defined(LMMS_HOST_X86_64) + _mm_pause(); #endif } } From 1531fb9e1a75dc6eb683570488d70a25ef3cbebe Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 17:57:42 +0100 Subject: [PATCH 14/16] MSVC: Fix include, fix GNU compiler flag --- plugins/OpulenZ/CMakeLists.txt | 2 ++ src/core/LocklessAllocator.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/OpulenZ/CMakeLists.txt b/plugins/OpulenZ/CMakeLists.txt index a80227ce232..58f661406a7 100644 --- a/plugins/OpulenZ/CMakeLists.txt +++ b/plugins/OpulenZ/CMakeLists.txt @@ -1,7 +1,9 @@ INCLUDE(BuildPlugin) # Avoid unused warnings for mididata.h +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") +ENDIF() INCLUDE_DIRECTORIES(adplug/src) diff --git a/src/core/LocklessAllocator.cpp b/src/core/LocklessAllocator.cpp index 3e8d3a7fd88..3133a1f0818 100644 --- a/src/core/LocklessAllocator.cpp +++ b/src/core/LocklessAllocator.cpp @@ -26,13 +26,12 @@ #include +#include "lmmsconfig.h" + #ifndef LMMS_BUILD_WIN32 #include #endif -#include "lmmsconfig.h" - - static const size_t SIZEOF_SET = sizeof( int ) * 8; From 3c9a1bbe5e7aaafd35f8d49ad8755cee0baf64da Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 22 Nov 2017 20:38:10 +0100 Subject: [PATCH 15/16] Fix Clang compilation with gig --- include/MicroTimer.h | 32 ++++---------------------------- include/MixerProfiler.h | 1 + src/core/CMakeLists.txt | 1 + src/core/MicroTimer.cpp | 27 +++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 src/core/MicroTimer.cpp diff --git a/include/MicroTimer.h b/include/MicroTimer.h index 523b691e9e9..2026619e2b0 100644 --- a/include/MicroTimer.h +++ b/include/MicroTimer.h @@ -25,42 +25,18 @@ #ifndef MICRO_TIMER #define MICRO_TIMER -#include "lmmsconfig.h" - #include -#include -#include "lmms_basics.h" - class MicroTimer { - using clock = std::chrono::steady_clock; using time_point = std::chrono::steady_clock::time_point; - static_assert (std::ratio_less_equal::value, "MicroTimer: steady_clock doesn't support microsecond resolution"); - public: - inline MicroTimer() - { - reset(); - } - - inline ~MicroTimer() - { - } - - inline void reset() - { - begin = clock::now(); - } - - inline int elapsed() const - { - auto now = clock::now(); - return std::chrono::duration_cast>(now - begin).count(); - } + MicroTimer(); + ~MicroTimer(); + void reset(); + int elapsed() const; private: time_point begin; diff --git a/include/MixerProfiler.h b/include/MixerProfiler.h index c519b767a7f..0c46c34cb0d 100644 --- a/include/MixerProfiler.h +++ b/include/MixerProfiler.h @@ -27,6 +27,7 @@ #include +#include "lmms_basics.h" #include "MicroTimer.h" class MixerProfiler diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 604a63c040e..49686f691b8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -34,6 +34,7 @@ set(LMMS_SRCS core/MemoryHelper.cpp core/MemoryManager.cpp core/MeterModel.cpp + core/MicroTimer.cpp core/Mixer.cpp core/MixerProfiler.cpp core/MixerWorkerThread.cpp diff --git a/src/core/MicroTimer.cpp b/src/core/MicroTimer.cpp new file mode 100644 index 00000000000..ba94f1c9a72 --- /dev/null +++ b/src/core/MicroTimer.cpp @@ -0,0 +1,27 @@ +#include "MicroTimer.h" + +using namespace std; +using namespace std::chrono; + +static_assert(ratio_less_equal::value, + "MicroTimer: steady_clock doesn't support microsecond resolution"); + +MicroTimer::MicroTimer() +{ + reset(); +} + +MicroTimer::~MicroTimer() +{ +} + +void MicroTimer::reset() +{ + begin = steady_clock::now(); +} + +int MicroTimer::elapsed() const +{ + auto now = steady_clock::now(); + return std::chrono::duration_cast>(now - begin).count(); +} From 7fdbcc3c7171936d8333c1fae0ede75b3e9fc7b2 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 23 Nov 2017 15:05:01 +0100 Subject: [PATCH 16/16] Xpressive: Fix Clang patch on macOS --- plugins/Xpressive/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Xpressive/CMakeLists.txt b/plugins/Xpressive/CMakeLists.txt index 8e4e33bcc1d..6db01f46de5 100644 --- a/plugins/Xpressive/CMakeLists.txt +++ b/plugins/Xpressive/CMakeLists.txt @@ -11,7 +11,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dexprtk_disable_rtl_vecops") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WERROR_FLAGS} -fexceptions") # See https://github.com/ArashPartow/exprtk/pull/9 -IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") EXECUTE_PROCESS(COMMAND patch exprtk/exprtk.hpp exprtk.hpp.patch WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_QUIET) ENDIF()