mirror of
https://github.com/openvswitch/ovs
synced 2025-10-27 15:18:06 +00:00
Fix C++ build issue when static_assert() is not available
This patch prevents compile errors if the C++ compiler does not support
C++11 or the support is not enabled.
VMWare-BZ: #1953215
Fixes: 994bfc2985 ("Automatically verify that OVS header files work OK in C++ also.")
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -59,9 +59,12 @@
|
|||||||
#define OFP_ASSERT(EXPR) \
|
#define OFP_ASSERT(EXPR) \
|
||||||
extern int (*build_assert(void))[ sizeof(struct { \
|
extern int (*build_assert(void))[ sizeof(struct { \
|
||||||
unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
|
unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
|
||||||
#else /* __cplusplus */
|
#elif __cplusplus >= 201103L
|
||||||
#define OFP_ASSERT(EXPR) static_assert(EXPR, "assertion failed")
|
#define OFP_ASSERT(EXPR) static_assert(EXPR, "assertion failed")
|
||||||
#endif /* __cplusplus */
|
#else /* __cplusplus < 201103L */
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#define OFP_ASSERT BOOST_STATIC_ASSERT
|
||||||
|
#endif /* __cplusplus < 201103L */
|
||||||
|
|
||||||
/* Version number:
|
/* Version number:
|
||||||
* Non-experimental versions released: 0x01 0x02
|
* Non-experimental versions released: 0x01 0x02
|
||||||
|
|||||||
@@ -243,9 +243,13 @@
|
|||||||
#ifdef __CHECKER__
|
#ifdef __CHECKER__
|
||||||
#define BUILD_ASSERT(EXPR) ((void) 0)
|
#define BUILD_ASSERT(EXPR) ((void) 0)
|
||||||
#define BUILD_ASSERT_DECL(EXPR) extern int (*build_assert(void))[1]
|
#define BUILD_ASSERT_DECL(EXPR) extern int (*build_assert(void))[1]
|
||||||
#elif defined(__cplusplus)
|
#elif defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
#define BUILD_ASSERT(EXPR) static_assert(EXPR, "assertion failed")
|
#define BUILD_ASSERT(EXPR) static_assert(EXPR, "assertion failed")
|
||||||
#define BUILD_ASSERT_DECL(EXPR) static_assert(EXPR, "assertion failed")
|
#define BUILD_ASSERT_DECL(EXPR) static_assert(EXPR, "assertion failed")
|
||||||
|
#elif defined(__cplusplus) && __cplusplus < 201103L
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
|
#define BUILD_ASSERT BOOST_STATIC_ASSERT
|
||||||
|
#define BUILD_ASSERT_DECL BOOST_STATIC_ASSERT
|
||||||
#elif (__GNUC__ * 256 + __GNUC_MINOR__ >= 0x403 \
|
#elif (__GNUC__ * 256 + __GNUC_MINOR__ >= 0x403 \
|
||||||
|| __has_extension(c_static_assert))
|
|| __has_extension(c_static_assert))
|
||||||
#define BUILD_ASSERT_DECL(EXPR) _Static_assert(EXPR, #EXPR)
|
#define BUILD_ASSERT_DECL(EXPR) _Static_assert(EXPR, #EXPR)
|
||||||
|
|||||||
Reference in New Issue
Block a user