From 2f579c3e670d6e56aa25d4a2aaca0dacbb76a73e Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 7 Sep 2023 21:47:40 -0400 Subject: [PATCH] Turn on Wextra and Wpedantic on clang/gcc Ignore unused-parameter; it is useful to document intent, but keep the rest of the warnings. gcc pragma ignore some vst3 headers to get there. If we merge #107 we will be able to turn on Werror also, at least on mac and linux. --- cmake/enable_sdks.cmake | 2 +- src/detail/vst3/process.cpp | 8 ++++---- src/detail/vst3/process.h | 11 +++++++++++ src/wrapasvst3.cpp | 6 +++--- src/wrapasvst3.h | 11 +++++++++++ src/wrapasvst3_entry.cpp | 2 +- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/cmake/enable_sdks.cmake b/cmake/enable_sdks.cmake index 9eafd2b9..727ae856 100644 --- a/cmake/enable_sdks.cmake +++ b/cmake/enable_sdks.cmake @@ -340,7 +340,7 @@ function(target_add_vst3_wrapper) ) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE -Wall) + target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE -Wall -Wextra -Wno-unused-parameter -Wpedantic) endif() if (APPLE) target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC macos_filesystem_support) diff --git a/src/detail/vst3/process.cpp b/src/detail/vst3/process.cpp index 959119a3..c0763ecb 100644 --- a/src/detail/vst3/process.cpp +++ b/src/detail/vst3/process.cpp @@ -49,7 +49,7 @@ namespace Clap if ( numInputs > 0) { _input_ports = new clap_audio_buffer_t[numInputs]; - for (int i = 0; i < numInputs; ++i) + for (auto i = 0U; i < numInputs; ++i) { clap_audio_buffer_t& bus = _input_ports[i]; Vst::BusInfo info; @@ -77,7 +77,7 @@ namespace Clap if (numOutputs > 0) { _output_ports = new clap_audio_buffer_t[numOutputs]; - for (int i = 0; i < numOutputs; ++i) + for (auto i = 0U; i < numOutputs; ++i) { clap_audio_buffer_t& bus = _output_ports[i]; Vst::BusInfo info; @@ -361,7 +361,7 @@ namespace Clap { // setting the buffers auto inbusses = _audioinputs->size(); - for (int i = 0; i < inbusses; ++i) + for (auto i = 0U; i < inbusses; ++i) { if (_vstdata->inputs[i].numChannels > 0) _input_ports[i].data32 = _vstdata->inputs[i].channelBuffers32; @@ -370,7 +370,7 @@ namespace Clap } auto outbusses = _audiooutputs->size(); - for (int i = 0; i < outbusses; ++i) + for (auto i = 0U; i < outbusses; ++i) { if (_vstdata->outputs[i].numChannels > 0) _output_ports[i].data32 = _vstdata->outputs[i].channelBuffers32; diff --git a/src/detail/vst3/process.h b/src/detail/vst3/process.h index c59aea1f..41d4bd83 100644 --- a/src/detail/vst3/process.h +++ b/src/detail/vst3/process.h @@ -13,10 +13,21 @@ */ #include + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#endif + #include #include #include #include + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include #include diff --git a/src/wrapasvst3.cpp b/src/wrapasvst3.cpp index b9a4b3af..c6a87651 100644 --- a/src/wrapasvst3.cpp +++ b/src/wrapasvst3.cpp @@ -398,11 +398,11 @@ void ClapAsVst3::addMIDIBusFrom(const clap_note_port_info_t* info, uint32_t inde void ClapAsVst3::updateAudioBusses() { - for ( int i = 0 ; i < audioInputs.size() ; ++i) + for ( auto i = 0U; i < audioInputs.size() ; ++i) { _processAdapter->activateAudioBus(Vst::kInput, i,audioInputs[i]->isActive()); } - for (int i = 0; i < audioOutputs.size(); ++i) + for (auto i = 0U; i < audioOutputs.size(); ++i) { _processAdapter->activateAudioBus(Vst::kOutput, i, audioOutputs[i]->isActive()); } @@ -667,7 +667,7 @@ void ClapAsVst3::param_rescan(clap_param_rescan_flags flags) vstflags |= Vst::RestartFlags::kMidiCCAssignmentChanged; } - vstflags |= ((flags & CLAP_PARAM_RESCAN_VALUES) ? Vst::RestartFlags::kParamValuesChanged : 0u); + vstflags |= ((flags & CLAP_PARAM_RESCAN_VALUES) ? (uint32_t)Vst::RestartFlags::kParamValuesChanged : 0u); vstflags |= ((flags & CLAP_PARAM_RESCAN_INFO) ? Vst::RestartFlags::kParamValuesChanged | Vst::RestartFlags::kParamTitlesChanged : 0u); if (vstflags != 0) { diff --git a/src/wrapasvst3.h b/src/wrapasvst3.h index 7458a21e..5403e5d9 100644 --- a/src/wrapasvst3.h +++ b/src/wrapasvst3.h @@ -14,10 +14,21 @@ */ #include "clap_proxy.h" + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#endif + #include #include #include #include + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "detail/vst3/plugview.h" #include "detail/os/osutil.h" #include "detail/clap/automation.h" diff --git a/src/wrapasvst3_entry.cpp b/src/wrapasvst3_entry.cpp index 078cbe11..764399bd 100644 --- a/src/wrapasvst3_entry.cpp +++ b/src/wrapasvst3_entry.cpp @@ -268,7 +268,7 @@ IPluginFactory* GetPluginFactoryEntryPoint() { char x[sizeof(g)*2+8]; char* o = x; constexpr char hexchar[] = "0123456789ABCDEF"; - for (int i = 0 ; i < sizeof(g) ; i++) + for (auto i = 0U ; i < sizeof(g) ; i++) { auto n = v[i]; *o++ = hexchar[(n >> 4) & 0xF];