diff --git a/src/sfizz/AudioBuffer.h b/src/sfizz/AudioBuffer.h index 3bc919d0..dcd80588 100644 --- a/src/sfizz/AudioBuffer.h +++ b/src/sfizz/AudioBuffer.h @@ -85,7 +85,7 @@ public: */ iterator channelWriter(size_t channelIndex) { - ASSERT(channelIndex < numChannels) + ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) return buffers[channelIndex]->data(); @@ -100,7 +100,7 @@ public: */ iterator channelWriterEnd(size_t channelIndex) { - ASSERT(channelIndex < numChannels) + ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) return buffers[channelIndex]->end(); @@ -115,7 +115,7 @@ public: */ const_iterator channelReader(size_t channelIndex) const { - ASSERT(channelIndex < numChannels) + ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) return buffers[channelIndex]->data(); @@ -130,7 +130,7 @@ public: */ const_iterator channelReaderEnd(size_t channelIndex) const { - ASSERT(channelIndex < numChannels) + ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) return buffers[channelIndex]->end(); @@ -145,7 +145,7 @@ public: */ absl::Span getSpan(size_t channelIndex) const { - ASSERT(channelIndex < numChannels) + ASSERT(channelIndex < numChannels); if (channelIndex < numChannels) return { buffers[channelIndex]->data(), buffers[channelIndex]->size() }; diff --git a/src/sfizz/Debug.h b/src/sfizz/Debug.h index 72d239bc..8479b6ec 100644 --- a/src/sfizz/Debug.h +++ b/src/sfizz/Debug.h @@ -14,16 +14,16 @@ // Break in source code #if (__x86_64__ || __i386__) #define ASSERTFALSE \ - { \ + do { \ std::cerr << "Assert failed at " << __FILE__ << ":" << __LINE__ << '\n'; \ __asm__("int3"); \ - } + } while (0) #elif (__arm__ || __aarch64__) #define ASSERTFALSE \ - { \ + do { \ std::cerr << "Assert failed at " << __FILE__ << ":" << __LINE__ << '\n'; \ __builtin_trap(); \ - } + } while (0) #endif #elif (_WIN32 || _WIN64) @@ -31,26 +31,28 @@ #pragma intrinsic(__debugbreak) #endif #define ASSERTFALSE \ - { \ + do { \ std::cerr << "Assert failed at " << __FILE__ << ":" << __LINE__ << '\n'; \ __debugbreak(); \ - } + } while (0) #else -#define ASSERTFALSE +#define ASSERTFALSE do {} while (0) #endif // Assert stuff #define ASSERT(expression) \ - if (!(expression)) \ - ASSERTFALSE + do { \ + if (!(expression)) \ + ASSERTFALSE \ + while (0) // Debug message #define DBG(ostream) do { std::cerr << ostream << '\n'; } while (0) #else // NDEBUG -#define ASSERTFALSE -#define ASSERT(expression) -#define DBG(ostream) +#define ASSERTFALSE do {} while (0) +#define ASSERT(expression) do {} while (0) +#define DBG(ostream) do {} while (0) #endif