Revision: 1287
http://assorted.svn.sourceforge.net/assorted/?rev=1287&view=rev
Author: yangzhang
Date: 2009-03-12 19:43:12 +0000 (Thu, 12 Mar 2009)
Log Message:
-----------
added assert.h
Added Paths:
-----------
cpp-commons/trunk/src/commons/assert.h
Added: cpp-commons/trunk/src/commons/assert.h
===================================================================
--- cpp-commons/trunk/src/commons/assert.h (rev 0)
+++ cpp-commons/trunk/src/commons/assert.h 2009-03-12 19:43:12 UTC (rev 1287)
@@ -0,0 +1,16 @@
+#ifndef COMMONS_ASSERT_H
+#define COMMONS_ASSERT_H
+
+#include <cassert>
+
+// Wraps the standard assert macro to avoids "unused variable" warnings when compiled away.
+// Inspired by: http://powerof2games.com/node/10
+// This is not the "default" because it does not conform to the requirements of the C standard,
+// which requires that the NDEBUG version be ((void) 0).
+#ifdef NDEBUG
+#define ASSERT(x) do { (void)sizeof(x); } while(0)
+#else
+#define ASSERT(x) assert(x)
+#endif
+
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|