3 ms·
I just recently discovered that modern C actually has syntax for forcing sized arrays as function arguments. You can do: foo(size_t n, char arr[restrict stati
by joveian 11y ago
I just recently discovered that modern C actually has syntax for forcing sized arrays as function arguments. You can do:
foo(size_t n, char arr[restrict static n])
The static qualifier here means "no really, I actually want the compiler to complain if the passed array isn't the size indicated". (because C doesn't have enough different meanings for the word "static" :( ). I haven't seen this in the wild yet or checked if gcc and clang actually implement it usefully, but it seems like it could be quite useful.