diff mbox

[ovs-dev] list.h: Define OVS_LIST_POISON statically

Message ID 1458332274-49510-1-git-send-email-nithin@vmware.com
State Superseded
Headers show

Commit Message

Nithin Raju March 18, 2016, 8:17 p.m. UTC
The previous definitions of these variables using designated
initializers caused a variety of issues when attempting to
compile with MSVC, particularly if including these headers from C++
code. By defining them like this, we can appease MSVC and keep the
definitions the same on all platforms.

Suggested-by: Yin Lin <linyi@vmware.com>
Signed-off-by: Nithin Raju <nithin@vmware.com>
---
 lib/list.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/lib/list.h b/lib/list.h
index f9c9d85..24c57ba 100644
--- a/lib/list.h
+++ b/lib/list.h
@@ -24,10 +24,14 @@ 
 #include "openvswitch/list.h"
 
 /* "struct ovs_list" with pointers that will (probably) cause segfaults if
- * dereferenced and, better yet, show up clearly in a debugger. */
-#define OVS_LIST_POISON \
-(struct ovs_list) { (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL, \
-                    (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL }
+ * dereferenced and, better yet, show up clearly in a debugger.
+
+ * MSVC2015 doesn't support designated initializers when compiling C++,
+ * and doesn't support ternary operators with non-designated initializers.
+ * So we use these static definitions rather than using initializer macros. */
+static const struct ovs_list OVS_LIST_POISON =
+    { (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL,
+      (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL };
 
 static inline void list_init(struct ovs_list *);
 static inline void list_poison(struct ovs_list *);