|
Lua could benefit from introducing ARRAY_FLEXIBLE_MEMBER define.With C99 or greater, struct with array flexible member can be:struct STRING_S{size_t size;char data[];};Before C99, I think maybe it needs to be used with zero,I haven't checked.struct STRING_S{size_t size;char data[0];};x86_64 plattform -O2#include <stdio.h>struct STRING_S{size_t size;char data[1];};typedef struct STRING_S string_t;int main(void){string_t str;printf("size=%zu\n", sizeof(str));return 0;}ASM generation compiler returned: 0Execution build compiler returned: 0Program returned: 0size=16So, some structs can be reduced by 8 bytes.struct Udatastruct CClosurestruct LClosure