4 ms·
Because the underlying OS API expects a char* as file name.
by habibur 5y ago
Because the underlying OS API expects a char* as file name.
- nyberg 5y agoRather, the underlying OS requires an array of bytes terminated by 0 which can be hidden behind a decent API. The type being poor at expressing this is not a limitation of the OS but of the C type system. E.g in zig this would be `[*:0]u8` which is "a pointer to a region of memory of unknown length terminated by a 0 sentinel value". It's still a pointer but nothing says the type system can't track more state around it.
- Animats 5y agoSo why isn't the Linux API properly encapsulated for C++? Rust does that. C++ got off on a weird I/O direction. That file << item << item; syntax never really caught on. Someone liked Currying too much.