Add soft asserts and fixed precision in debug messages

This commit is contained in:
Paul Ferrand 2020-05-29 13:55:11 +02:00
parent 7b016e5e40
commit 011d02cfca

View file

@ -8,7 +8,6 @@
#if !defined(NDEBUG) || defined(SFIZZ_ENABLE_RELEASE_ASSERT)
#include <iostream>
#include <iomanip>
// Break in source code
#if defined(_WIN32) && defined(_MSC_VER)
@ -40,16 +39,30 @@
ASSERTFALSE; \
} while (0)
#define CHECKFALSE \
do { \
std::cerr << "Check failed at " << __FILE__ << ":" << __LINE__ << '\n'; \
} while (0)
#define CHECK(expression) \
do { \
if (!(expression)) \
CHECKFALSE; \
} while (0)
#else // NDEBUG
#define ASSERTFALSE do {} while (0)
#define ASSERT(expression) do {} while (0)
#define CHECKFALSE do {} while (0)
#define CHECK(expression) do {} while (0)
#endif
// Debug message
#if !defined(NDEBUG) || defined(SFIZZ_ENABLE_RELEASE_DBG)
#include <iostream>
#include <iomanip>
#define DBG(ostream) do { std::cerr << std::fixed << std::setprecision(2) << ostream << '\n'; } while (0)
#else
#define DBG(ostream) do {} while (0)