Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, I am not talking about a runtime-allocated structure. I’m talking about a function that can accept and operate on arrays of different sizes, all of which are fixed size at their declaration site, and all stored on the stack.

There is no reason this shouldn’t be possible. It should not require fat pointers at all because the size information is known at compile time.



AFAICT you’d either have to pass the length at runtime somehow, or treat the function as a generic/template and generate a separate version for each separate N it’s called with. The latter would be pretty far from the ethos of C, imo.


> AFAICT you’d either have to pass the length at runtime somehow

This is exactly the solution proposed in TFA..


This could be done by storing the length of the array before the first element. It wouldn’t even need to be done in all cases, only if the length is actually used.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: