diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index b7fda927..015ff49e 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -269,7 +269,7 @@ public: /* * Get length of the string. */ - std::size_t length() const noexcept + size_t length() const noexcept { return fBufferLen; } @@ -295,7 +295,7 @@ public: */ bool contains(const char c) const noexcept { - for (std::size_t i=0; i(ret); + return static_cast(ret); } if (found != nullptr) @@ -460,7 +460,7 @@ public: * Find the last occurrence of character 'c' in the string. * Returns "length()" if the character is not found. */ - std::size_t rfind(const char c, bool* const found = nullptr) const noexcept + size_t rfind(const char c, bool* const found = nullptr) const noexcept { if (fBufferLen == 0 || c == '\0') { @@ -469,7 +469,7 @@ public: return fBufferLen; } - for (std::size_t i=fBufferLen; i > 0; --i) + for (size_t i=fBufferLen; i > 0; --i) { if (fBuffer[i-1] == c) { @@ -488,7 +488,7 @@ public: * Find the last occurrence of string 'strBuf' in the string. * Returns "length()" if the string is not found. */ - std::size_t rfind(const char* const strBuf, bool* const found = nullptr) const noexcept + size_t rfind(const char* const strBuf, bool* const found = nullptr) const noexcept { if (found != nullptr) *found = false; @@ -496,12 +496,12 @@ public: if (fBufferLen == 0 || strBuf == nullptr || strBuf[0] == '\0') return fBufferLen; - const std::size_t strBufLen(std::strlen(strBuf)); + const size_t strBufLen(std::strlen(strBuf)); - std::size_t ret = fBufferLen; + size_t ret = fBufferLen; const char* tmpBuf = fBuffer; - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (std::strstr(tmpBuf+1, strBuf) == nullptr && std::strncmp(tmpBuf, strBuf, strBufLen) == 0) { @@ -532,7 +532,7 @@ public: { DISTRHO_SAFE_ASSERT_RETURN(before != '\0' /* && after != '\0' */, *this); - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (fBuffer[i] == before) fBuffer[i] = after; @@ -551,7 +551,7 @@ public: if (fBufferLen == 0) return *this; - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (fBuffer[i] == c) { @@ -567,7 +567,7 @@ public: /* * Truncate the string to size 'n'. */ - String& truncate(const std::size_t n) noexcept + String& truncate(const size_t n) noexcept { if (n >= fBufferLen) return *this; @@ -583,7 +583,7 @@ public: */ String& toBasic() noexcept { - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (fBuffer[i] >= '0' && fBuffer[i] <= '9') continue; @@ -607,7 +607,7 @@ public: { static constexpr const char kCharDiff = 'a' - 'A'; - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z') fBuffer[i] = static_cast(fBuffer[i] + kCharDiff); @@ -623,7 +623,7 @@ public: { static constexpr const char kCharDiff = 'a' - 'A'; - for (std::size_t i=0; i < fBufferLen; ++i) + for (size_t i=0; i < fBufferLen; ++i) { if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z') fBuffer[i] = static_cast(fBuffer[i] - kCharDiff); @@ -688,31 +688,28 @@ public: // base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html // Copyright (C) 2004-2008 René Nyffenegger - static String asBase64(const void* const data, const std::size_t dataSize) + static String asBase64(const void* const data, const size_t dataSize) { static constexpr const char* const kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; - #ifndef _MSC_VER - const std::size_t kTmpBufSize = std::min(d_nextPowerOf2(static_cast(dataSize/3)), 65536U); - #else - constexpr std::size_t kTmpBufSize = 65536U; - #endif + const size_t strBufSize = std::min(d_nextPowerOf2(static_cast(dataSize/3)), 65536U); + char* strBuf = static_cast(std::malloc(strBufSize)); + DISTRHO_SAFE_ASSERT_RETURN(strBuf != nullptr, String()); - const uchar* bytesToEncode((const uchar*)data); + strBuf[strBufSize] = '\0'; + size_t strBufIndex = 0; + + const uchar* bytesToEncode = static_cast(data); uint i=0, j=0; uint charArray3[3], charArray4[4]; - char strBuf[kTmpBufSize + 1]; - strBuf[kTmpBufSize] = '\0'; - std::size_t strBufIndex = 0; - String ret; - for (std::size_t s=0; s> 6); charArray4[3] = charArray3[2] & 0x3f; - for (i=0; i<4; ++i) + for (i = 0; i < 4; ++i) strBuf[strBufIndex++] = kBase64Chars[charArray4[i]]; - if (strBufIndex >= kTmpBufSize-7) + if (strBufIndex >= strBufSize - 7) { strBuf[strBufIndex] = '\0'; strBufIndex = 0; @@ -739,7 +736,7 @@ public: if (i != 0) { - for (j=i; j<3; ++j) + for (j = i; j < 3; ++j) charArray3[j] = '\0'; charArray4[0] = (charArray3[0] & 0xfc) >> 2; @@ -747,7 +744,7 @@ public: charArray4[2] = ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6); charArray4[3] = charArray3[2] & 0x3f; - for (j=0; j<4 && i<3 && j(std::malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); @@ -1080,7 +1075,7 @@ public: private: char* fBuffer; // the actual string buffer - std::size_t fBufferLen; // string length + size_t fBufferLen; // string length bool fBufferAlloc; // wherever the buffer is allocated, not using _null() /* @@ -1101,7 +1096,7 @@ private: * - Allocates string only if 'strBuf' is not null and new string contents are different * - If 'strBuf' is null, 'size' must be 0 */ - void _dup(const char* const strBuf, const std::size_t size = 0) noexcept + void _dup(const char* const strBuf, const size_t size = 0) noexcept { if (strBuf != nullptr) { @@ -1158,9 +1153,9 @@ String operator+(const String& strBefore, const char* const strBufAfter) noexcep if (strBefore.isEmpty()) return String(strBufAfter); - const std::size_t strBeforeLen = strBefore.length(); - const std::size_t strBufAfterLen = std::strlen(strBufAfter); - const std::size_t newBufSize = strBeforeLen + strBufAfterLen; + const size_t strBeforeLen = strBefore.length(); + const size_t strBufAfterLen = std::strlen(strBufAfter); + const size_t newBufSize = strBeforeLen + strBufAfterLen; char* const newBuf = static_cast(malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); @@ -1178,9 +1173,9 @@ String operator+(const char* const strBufBefore, const String& strAfter) noexcep if (strBufBefore == nullptr || strBufBefore[0] == '\0') return strAfter; - const std::size_t strBufBeforeLen = std::strlen(strBufBefore); - const std::size_t strAfterLen = strAfter.length(); - const std::size_t newBufSize = strBufBeforeLen + strAfterLen; + const size_t strBufBeforeLen = std::strlen(strBufBefore); + const size_t strAfterLen = strAfter.length(); + const size_t newBufSize = strBufBeforeLen + strAfterLen; char* const newBuf = static_cast(malloc(newBufSize + 1)); DISTRHO_SAFE_ASSERT_RETURN(newBuf != nullptr, String()); diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp index 686341a8..a45f927b 100644 --- a/distrho/src/DistrhoPluginVST2.cpp +++ b/distrho/src/DistrhoPluginVST2.cpp @@ -398,8 +398,8 @@ public: { parameterValues = new float[parameterCount]; - for (uint32_t i=0; i < parameterCount; ++i) - parameterValues[i] = NAN; + for (uint32_t i = 0; i < parameterCount; ++i) + parameterValues[i] = fPlugin.getParameterDefault(i); } #if DISTRHO_PLUGIN_WANT_MIDI_INPUT diff --git a/distrho/src/jackbridge/JackBridge.cpp b/distrho/src/jackbridge/JackBridge.cpp index 7c5633d0..c4c44b54 100644 --- a/distrho/src/jackbridge/JackBridge.cpp +++ b/distrho/src/jackbridge/JackBridge.cpp @@ -68,6 +68,9 @@ typedef void* lib_t; # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wdeprecated-declarations" # pragma clang diagnostic ignored "-Wunused-but-set-variable" +# if __clang_major__ >= 17 +# pragma clang diagnostic ignored "-Wvla-cxx-extension" +# endif # endif # include "RtAudioBridge.hpp" # ifdef RTAUDIO_API_TYPE