X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.h;h=5839e5b6c4ce1ccd52ac65f2364a9d6c1e095663;hp=082d1146a7f4c86c2d935ffeaa62307f6575b884;hb=37f56fcbe571b2322243f6de59494bf9e0cbb37a;hpb=34f5f331bd3b643949ccbb0c3488af2823634d59 diff --git a/util.h b/util.h index 082d114..5839e5b 100644 --- a/util.h +++ b/util.h @@ -3,13 +3,11 @@ // Various utilities. +#include #include #include - -#include #include - -#include "opengl.h" +#include #define BUFFER_OFFSET(i) ((char *)NULL + (i)) @@ -49,4 +47,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)