3 ms·
> @intToPtr([]allowzero const u8, 0 [0..@ptrToInt(&__end_init)] vs > (int*)0 They sure make you pay though the nose to cast in zig -- maybe a good thing?
by __turbobrew__ 8y ago
> @intToPtr([]allowzero const u8, 0 [0..@ptrToInt(&__end_init)]
vs
> (int*)0
They sure make you pay though the nose to cast in zig -- maybe a good thing?
- AnIdiotOnTheNet 8y agoZig's type system tries to be aware of what its pointing to. Is it an array of comptime known length? An array of unknown length? An array of runtime known length? or a single item? Is it mutable? What's its alignment requirement? etc. It even has a pointer type for "something that came from C, who the hell knows". There is an accepted proposal to have pointer types for null-terminated blocks of memory too. So when you create a pointer out of thin air, you have to inform the type system precisely what kind of pointer it is. That's why it is so much more gnarly than C, it wants you to be explicit.