When using CDS_LIST_HEAD_INIT in a C++ program, we get (with clang
rather than gcc, because the error message is clearer):
/home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: error: ISO C++ requires field designators to be specified in declaration order; field 'prev' will be initialized after field 'next' [-Werror,-Wreorder-init-list]
.head = CDS_LIST_HEAD_INIT(list.head),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/urcu/include/urcu/list.h:49:53: note: expanded from macro 'CDS_LIST_HEAD_INIT'
#define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
^~~~~~~~~~~~~~~
/home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: note: previous initialization for field 'prev' is here
.head = CDS_LIST_HEAD_INIT(list.head),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/urcu/include/urcu/list.h:49:44: note: expanded from macro 'CDS_LIST_HEAD_INIT'
#define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
^~~~~~~
Fix that by swapping the initializers in CDS_LIST_HEAD_INIT.
Change-Id: Ib127b9cc128fd64f5b2ae028e093be42ca10f437
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
#define CDS_INIT_LIST_HEAD(ptr) \
(ptr)->next = (ptr)->prev = (ptr)
-#define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
+#define CDS_LIST_HEAD_INIT(name) { .next = &(name), .prev = &(name) }
/* Add new element at the head of the list. */
static inline