You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/21 15:11:31 UTC

[incubator-nuttx] branch master updated: assert: static_assert is not support in c standard C89,C99.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 913c7148e5 assert: static_assert is not support in c standard C89,C99.
913c7148e5 is described below

commit 913c7148e54cecc05e5e2f144718bdb659b9f2b5
Author: wangbowen6 <wa...@xiaomi.com>
AuthorDate: Tue Apr 19 20:31:34 2022 +0800

    assert: static_assert is not support in c standard C89,C99.
    
    Signed-off-by: wangbowen6 <wa...@xiaomi.com>
---
 include/assert.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/assert.h b/include/assert.h
index b7098a906e..51dae09542 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -77,7 +77,13 @@
  */
 
 #ifndef __cplusplus
-#  define static_assert _Static_assert
+#  if defined(__STDC_VERSION__) && __STDC_VERSION__  > 199901L
+#    define static_assert _Static_assert
+#  else
+#    define static_assert(cond, msg) \
+       extern int (*__static_assert_function (void)) \
+       [!!sizeof (struct { int __error_if_negative: (cond) ? 2 : -1; })]
+#  endif
 #endif
 
 /****************************************************************************