diff mbox

odp_debug.h: Add ODP_STATIC_ASSERT

Message ID 1398185660-25698-1-git-send-email-mike.holmes@linaro.org
State Accepted
Headers show

Commit Message

Mike Holmes April 22, 2014, 4:54 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 include/odp_debug.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ola Liljedahl April 22, 2014, 7:35 p.m. UTC | #1
_Static_assert() vs. _static_assert? Are both supported in C99 or
common extensions? I Google and just get confused.

What about all the usages of the old ODP_ASSERT which ought to be
converted to ODP_STATIC_ASSERT?
Bill Fischofer April 22, 2014, 7:38 p.m. UTC | #2
The C11 construct is _Static_assert() (with the caps).  Agree we need to do
a find/replace for all uses as part of this change.

Bill


On Tue, Apr 22, 2014 at 2:35 PM, Ola Liljedahl <ola.liljedahl@linaro.org>wrote:

> _Static_assert() vs. _static_assert? Are both supported in C99 or
> common extensions? I Google and just get confused.
>
> What about all the usages of the old ODP_ASSERT which ought to be
> converted to ODP_STATIC_ASSERT?
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/include/odp_debug.h b/include/odp_debug.h
index 4d4f04e..e35c1ac 100644
--- a/include/odp_debug.h
+++ b/include/odp_debug.h
@@ -43,6 +43,12 @@  extern "C" {
 #define ODP_ASSERT(cond, msg)  typedef char msg[(cond) ? 1 : -1]
 
 /**
+ * Compile time assertion-macro - fail compilation if cond is false.
+ * @note This macro has zero runtime overhead
+ */
+#define ODP_STATIC_ASSERT(cond, msg)  _static_assert(cond, msg)
+
+/**
  * Debug printing macro, which prints output when DEBUG flag is set.
  */
 #define ODP_DBG(fmt, ...) \