]> git.sesse.net Git - movit/blobdiff - util.h
Run include-what-you-use over all of movit. Some hand tuning.
[movit] / util.h
diff --git a/util.h b/util.h
index 082d1146a7f4c86c2d935ffeaa62307f6575b884..5839e5b6c4ce1ccd52ac65f2364a9d6c1e095663 100644 (file)
--- a/util.h
+++ b/util.h
@@ -3,13 +3,11 @@
 
 // Various utilities.
 
+#include <GL/glew.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-#include <string>
 #include <Eigen/Core>
-
-#include "opengl.h"
+#include <string>
 
 #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)