Fix C++ array_pop

This commit is contained in:
2025-12-14 02:31:25 +00:00
parent de9ce5791a
commit b11ee05df4

View File

@@ -50,11 +50,14 @@ BEGIN_C_LINKAGE
\ \
return (TYPE *)(header + 1); \ return (TYPE *)(header + 1); \
}()) }())
#define wapp_array_pop(TYPE, ARRAY_PTR) \ #define wapp_array_pop(TYPE, ARRAY_PTR) ([&]() { \
(ARRAY_PTR != NULL && _array_count((u8 *)ARRAY_PTR) > 0 ? \ if (ARRAY_PTR != NULL || _array_count((u8 *)ARRAY_PTR) == 0) { \
*((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))) : \ TYPE result{}; \
TYPE{} \ return result; \
) } \
\
return *((TYPE *)_array_pop((u8 *)ARRAY_PTR, sizeof(TYPE))); \
}())
#else #else
#define _stack_array(TYPE, SIZE) struct { ArrayHeader header; TYPE items[SIZE]; } #define _stack_array(TYPE, SIZE) struct { ArrayHeader header; TYPE items[SIZE]; }
#define wapp_array(TYPE, ...) \ #define wapp_array(TYPE, ...) \