Re:Why Use Pascal?
by filmor on Saturday July 08, 2023 @04:43PM
(#36648537)
They are pretty much everywhere when statically allocated.
[ Parent
| on HN ]
well, not in c.
I believe they are in C, but arrays degrade to pointers when you look at them wrong, and _those_ don't have length as part of their type.
At least I'm seeing: `array type 'int[3]'` in messages when I tried to do something wrong with it quick to get an error message (using llvm), maybe that's a compiler specific thing.
> when you look at them wrong
no, almost whenever you look at them. it is very hard to carry around the size of an array in C.
> At least I'm seeing: `array type 'int[3]'` in messages when I tried to do something wrong with it quick to get an error message (using llvm), maybe that's a compiler specific thing.
post some code that illustrates what you are talking about
I was trying to get clang to throw an error that included type information to double check what it thought the type was. Quickest thing I could think of was trying to assign to an array.
The exact error in question was: error: array type 'int[3]' is not assignable
Which seems to imply that clang is considering the length to be part of the type.
edit: You asked for code (my apologies that it's rather trivial).
int x[3] = {1, 2, 3};
int y[3];
y = x;