2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +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:
Yi-Hung Wei
2017-09-12 15:43:03 -07:00
committed by Ben Pfaff
parent 4a0a2c24a4
commit 5e8bed8373
2 changed files with 10 additions and 3 deletions

View File

@@ -59,9 +59,12 @@
#define OFP_ASSERT(EXPR) \
extern int (*build_assert(void))[ sizeof(struct { \
unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
#else /* __cplusplus */
#elif __cplusplus >= 201103L
#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:
* Non-experimental versions released: 0x01 0x02