diff --git a/src/primitives/array/array.h b/src/primitives/array/array.h index eac8e38..52be0bd 100644 --- a/src/primitives/array/array.h +++ b/src/primitives/array/array.h @@ -50,11 +50,14 @@ BEGIN_C_LINKAGE \ return (TYPE *)(header + 1); \ }()) -#define wapp_array_pop(TYPE, ARRAY_PTR) \ - (ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR) > 0 ? \ - *((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \ - TYPE{} \ - ) +#define wapp_array_pop(TYPE, ARRAY_PTR) ([&]() { \ + if (ARRAY_PTR != NULL || _array_count((u8 *)ARRAY_PTR) == 0) { \ + TYPE result{}; \ + return result; \ + } \ + \ + return *((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))); \ +}()) #else #define _stack_array(TYPE, SIZE) struct { ArrayHeader header; TYPE items[SIZE]; } #define wapp_array(TYPE, ...) \