Arrays without code generation #6

Merged
abdelrahman merged 15 commits from no-codegen-array into main 2025-12-14 01:47:43 +00:00
3 changed files with 6 additions and 2 deletions
Showing only changes of commit 2ccdb4ca74 - Show all commits

View File

@@ -1,3 +1,5 @@
// vim:fileencoding=utf-8:foldmethod=marker
#include "./array.h"
#include "../../common/assert/assert.h"
#include "../mem_allocator/mem_allocator.h"

View File

@@ -1,3 +1,5 @@
// vim:fileencoding=utf-8:foldmethod=marker
#ifndef ARRAY_H
#define ARRAY_H

View File

@@ -37,14 +37,14 @@ typedef const Str8 Str8RO;
#ifdef WAPP_PLATFORM_CPP
// Uses a lambda to achieve the same behaviour achieved by the C macro
#define wapp_str8_buf(CAPACITY) ([&](){ \
wapp_persist c8 buf[CAPACITY] = {}; \
wapp_persist c8 buf[CAPACITY] = {}; \
memset(buf, 0, CAPACITY); \
return Str8{CAPACITY, 0, buf}; \
}())
// Uses a lambda to achieve the same behaviour achieved by the C macro
#define wapp_str8_lit(STRING) ([&]() { \
wapp_persist c8 buf[sizeof(STRING) * 2] = {}; \
wapp_persist c8 buf[sizeof(STRING) * 2] = {}; \
memcpy(buf, STRING, sizeof(STRING)); \
return Str8{(sizeof(STRING) - 1) * 2, sizeof(STRING) - 1, buf}; \
}())