X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.h;h=b01d62c00f00588a21b2587e6387f649b6b3bdc1;hp=082d1146a7f4c86c2d935ffeaa62307f6575b884;hb=45c9a794d20296b46c5200fde481af9bf9e810f9;hpb=34f5f331bd3b643949ccbb0c3488af2823634d59 diff --git a/util.h b/util.h index 082d114..b01d62c 100644 --- a/util.h +++ b/util.h @@ -49,4 +49,17 @@ void combine_two_samples(float w1, float w2, float *offset, float *total_weight, #define check_error() { int err = glGetError(); if (err != GL_NO_ERROR) { printf("GL error 0x%x at %s:%d\n", err, __FILE__, __LINE__); exit(1); } } #endif +#ifdef __GNUC__ +#define MUST_CHECK_RESULT __attribute__((warn_unused_result)) +#else +#define MUST_CHECK_RESULT +#endif + +// CHECK() is like assert(), but retains any side effects no matter the compilation mode. +#ifdef NDEBUG +#define CHECK(x) (void)(x) +#else +#define CHECK(x) do { bool ok = x; if (!ok) { fprintf(stderr, "%s:%d: %s: Assertion `%s' failed.\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); abort(); } } while (false) +#endif + #endif // !defined(_UTIL_H)