#define ALL_LIST_ELEMENTS(list, node, nextnode, data) \
(node) = listhead(list), ((data) = NULL); \
(node) != NULL \
- && ((data) = listgetdata(node), (nextnode) = node->next, 1); \
+ && ((data) = static_cast(data, listgetdata(node)), \
+ (nextnode) = node->next, 1); \
(node) = (nextnode), ((data) = NULL)
/* read-only list iteration macro.
*/
#define ALL_LIST_ELEMENTS_RO(list, node, data) \
(node) = listhead(list), ((data) = NULL); \
- (node) != NULL && ((data) = listgetdata(node), 1); \
+ (node) != NULL && ((data) = static_cast(data, listgetdata(node)), 1); \
(node) = listnextnode(node), ((data) = NULL)
/* these *do not* cleanup list nodes and referenced data, as the functions
#include "zassert.h"
+/*
+ * Add explicit static cast only when using a C++ compiler.
+ */
+#ifdef __cplusplus
+#define static_cast(l, r) static_cast<decltype(l)>((r))
+#else
+#define static_cast(l, r) (r)
+#endif
+
#ifndef HAVE_STRLCAT
size_t strlcat(char *__restrict dest,
const char *__restrict src, size_t destsize);