Earlier quoted context omitted.
What is **int[3][5]
A syntax error. You need a variable name, not a type name, in the middle.
C array types are weird
11–20 of 148 posts
Re: C array types are weird
#12Re: C array types are weird
#13Re: C array types are weird
#14Re: C array types are weird
#15In practice, the [static n] notation can give you useful warnings and bounds checking. https://godbolt.org/z/PzcjW4zKK And while the (*array_ptr)[3] notation take a moment to get used to, it is very logical. If you have a pointer to an array, you dereference it first and then indx into it. Again, useful for bounds checking: https://godbolt.org/z/ao1so9KP7
Not sure why, maybe it doesn't feel like C anymore, maybe it feels hacky?
typically if you're passed an array you'd want to get more anyway, so you'd get passed a struct. Not sure.
Re: C array types are weird
#16This is one of the things that I feel is an inappropriate abstraction that is around for historical reasons. When I do FFI to call C from rust, I usually wrap the generated API (Which is pointer based) into rust's &[] array syntax. Arrays/lists/Vecs etc in most non-C languages feel like an abstraction over a collection of items; I feel like C's exposing the pointer directly is taking a low-level memory/MMIO operation…
This talk – "Programming without pointers" – by Andrew Kelley may be interesting to you. https://www.hytradboi.com/2025/05c72e39-c07e-41bc-ac40-85e83...
Re: C array types are weird
#17[flagged]
Re: C array types are weird
#18Re: C array types are weird
#19In practice, the [static n] notation can give you useful warnings and bounds checking. https://godbolt.org/z/PzcjW4zKK And while the (*array_ptr)[3] notation take a moment to get used to, it is very logical. If you have a pointer to an array, you dereference it first and then indx into it. Again, useful for bounds checking: https://godbolt.org/z/ao1so9KP7
What is **int[3][5]