Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some preliminary work on adding a
c_char
type to correspond to thechar
c type. Any questions/discussion is welcome.Why do we need this?
Currently a
char
type is translated from c as au8
. This is wrong for two reasons.First, the sign of a
char
for each platform is implementation defined. This causes issues since it means bothu8
andi8
are not compatible withchar
. This is easy to see when trying to create an exportable zig function which takes achar
compatible parameter (impossible with the status quo). Even common targets differ; arm for example uses an unsignedchar
vs. x86_64 using a signedchar
.Second, a
char
is not necessarily 8 bits. However, on all common platforms this is true (and I think all LLVM support?). This is of much lower concern and I think the assumption that it is always 8-bits is fine to keep right now.What to add
cstring
types which now are of type[]const c_char
instead of[]const u8
.Questions
Would implicit casting from
[]const c_char
to[]const u8
make sense? I've had a brief look at changing the required os functions and it makes usage a fair bit more annoying to use c strings with low-level os zig functions. I may follow up with a port of the linux os functions and see how that fares. We can always do an explicit@ptrCast
.