From d8c1a999cc566b8943003ad5281abc6eefcda519 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 7 Jul 2023 16:23:35 +0200 Subject: Issue #60: fixed compiler compability. --- include/stc/ccommon.h | 4 ++-- misc/examples/intrusive.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index bbf1579b..63ce5b09 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -69,8 +69,8 @@ #define c_LITERAL(T) T #else #define _i_alloc(T) ((T*)i_malloc(c_sizeof(T))) - #define _i_new(T, ...) ((T*)memcpy(_i_alloc(T), (T[]){__VA_ARGS__}, sizeof(T))) - #define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), (T[]){__VA_ARGS__}, sizeof(T))) + #define _i_new(T, ...) ((T*)memcpy(_i_alloc(T), ((T[]){__VA_ARGS__}), sizeof(T))) + #define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), ((T[]){__VA_ARGS__}), sizeof(T))) #define c_LITERAL(T) (T) #endif #define c_malloc(sz) malloc(c_i2u(sz)) diff --git a/misc/examples/intrusive.c b/misc/examples/intrusive.c index 0d59c5ab..e3939f4e 100644 --- a/misc/examples/intrusive.c +++ b/misc/examples/intrusive.c @@ -17,7 +17,7 @@ void printList(List list) { int main() { List list = {0}; c_forlist (i, int, {6, 9, 3, 1, 7, 4, 5, 2, 8}) - List_push_back_node(&list, c_new(List_node, {.value=*i.ref})); + List_push_back_node(&list, c_new(List_node, {0, *i.ref})); printList(list); -- cgit v1.2.3