3 ms·
That's related to something I would like which is to be able to set the number of elements in an incomplete struct. struct foo { size_t elements;
by Gibbon1 2y ago
That's related to something I would like which is to be able to set the number of elements in an incomplete struct.
struct foo
{
size_t elements;
int data[];
};
foo foo123 = {.elements = array_size(data), .data = {1, 2, 3}};
or
struct str
{
size_t sz;
char str[];
};
str s123 = {.sz = strlen(.str), .str = "123"};
- uecker 2y agoClang and GCC just got the [[counted_by()]] attribute to help protect such structs in the kernel. But yes, native syntax for this would be nice.