a_chou has quit [Remote host closed the connection]
earnestly has joined #zig
<justin_smith>
I'm tripping over myself with the declaratio of a null terminated array of null terminated arrays
<justin_smith>
(this data comes from an api that gives a null terminated array of "port names", each is a null terminated string, port names are registered by other running apps so no compile time length info is possible)
<justin_smith>
"[*:0][*:0]const u8" feels like it should be the right type, but the compiler is rejecting that with "error: expected type '[*:0]const u8', found 'comptime_int'"
<justin_smith>
"[][*:0]const u8" works but doesn't contain as much information
radgeRayden has joined #zig
<fengb>
The type you’re probably looking for is `[*:null]?[*:0]const u8`
<fengb>
It’s used sparingly in stdlib
<justin_smith>
makes sense - I'll try that
<justin_smith>
also is there a variant of ptrCast for []>?
<justin_smith>
for [] that is. maybe once you've declared [] that means you don't plan on any casts? or else I'm not understanding this compiler error
<justin_smith>
still trying to make this type declaration something better than [*c] for a program that was working but underspecified / less than idel
<justin_smith>
*ideal
ur5us has joined #zig
reductum has quit [Quit: WeeChat 2.9]
<justin_smith>
what's the correct way to index a pointer I get from a c API I don't control?
dermetfan has quit [Ping timeout: 272 seconds]
<justin_smith>
style question also: if I'm using a var to hold the return value before converting to a saner type, is there something better than "[*c][*c]const u8" that the type checker will allow in an explicit declaration (previously I was cheating by letting inference type it that way)
nephele_ has joined #zig
nephele has quit [Ping timeout: 272 seconds]
nephele_ is now known as nephele
<andrewrk>
yeah, give it the correct type and zig will let it implicit coerce from the c pointers
swills has joined #zig
<justin_smith>
OK wow, it looks like this "sleep(-1)" idiom that was used silently coerced -1 to a large unsigned value(???)
<justin_smith>
most of my bitcasts from translate-c were trivial but this is weird
waleee-cl has quit [Quit: Connection closed for inactivity]
<justin_smith>
I guess it's safe to replace it with 0xFFFFFFFF
<andrewrk>
that's common in C
<andrewrk>
you can use std.math.maxInt(u32)
dputtick has quit [Ping timeout: 260 seconds]
dputtick has joined #zig
<justin_smith>
it's like a pun: using -1 seems to indicate "some out of band sleep duration" but really just gets converted to max_int thanks to 2's complement encoding and a bad cast
joey152 has joined #zig
ur5us has quit [Ping timeout: 244 seconds]
<leeward>
Yeah, that's a common idiom. Also ~0
ur5us has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
squeek502 has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
knebulae has quit [Read error: Connection reset by peer]
<pixelherodev>
Heh, I actually used -2 for something :P
<pixelherodev>
I have a graphics lib that allows manually setting width, doing it automatically if it's -1
<pixelherodev>
So I used -2 to indicate "expand to screen" :P
_whitelogger has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
tdeo has quit [Remote host closed the connection]
cole-h has joined #zig
gert_ has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
squeek502 has joined #zig
frett27 has joined #zig
gert_ has quit [Quit: WeeChat 2.9]
waleee-cl has joined #zig
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
frett27 has quit [Ping timeout: 265 seconds]
marnix has quit [Ping timeout: 260 seconds]
Joey152 has quit [Remote host closed the connection]
_whitelogger has joined #zig
cole-h has quit [Quit: Goodbye]
earnestly has joined #zig
mixi has quit [Quit: connection reset by purr]
mixi has joined #zig
dermetfan has joined #zig
marnix has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
pangey__ has quit [Quit: bye]
pangey has joined #zig
ask6155 has joined #zig
<ask6155>
Hello
<ikskuh>
heya
<ask6155>
I have a buffer with only one number and I give it to parseInt(u8, buffer, 10) but it gives me invalid character error
<ikskuh>
how do you init the buffer?
<ask6155>
buffer: [64]u8 = undefined and then I make a slice of it. I pass it to the reader, it fills it with input then I pass the slice to parseInt
<ikskuh>
can you give the full code example?
<ikskuh>
you're maybe passing the whole 64 bytes
<ask6155>
ok
<ask6155>
var user_input: [64]u8 = undefined;
<ask6155>
var user_input_slice = user_input[0..]; //Making a slice from the buffer
<ask6155>
I have a 16 length buffer. While reading input if I put 17 chars I do gracefully handle the error and restart the loop but the 17th char is then given to the buffer. How do I fix that?
<ikskuh>
it depends on how you do all of this
<Nypsie[m]>
read() only reads until the length of the buffer, this means that if the buffer is smaller than the entire stream, it will resume at the position the previous read() got to
<ask6155>
How do I make it so it doesn't resume from where it left off?
<ikskuh>
that depends on the stream
<ikskuh>
you can use readAllAlloc for example
<ask6155>
hmm
<ask6155>
wait you can use zig as a c++ compiler too?
<Nypsie[m]>
Yes
<ask6155>
does it do cross compilation?
<Nypsie[m]>
Yep
<ask6155>
when whas this added?
<Nypsie[m]>
Hmmm, ages ago I think
<squeek502>
shortly after zig cc
wootehfoot has joined #zig
dddddd_ has joined #zig
dddddd has quit [Ping timeout: 264 seconds]
<ask6155>
is wasm32 support broken currently?
m6w6 has quit [Ping timeout: 256 seconds]
riba has quit [Ping timeout: 256 seconds]
m6w6 has joined #zig
dddddd_ is now known as dddddd
ask6155 has left #zig ["Later!"]
riba has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
riba has quit [Ping timeout: 272 seconds]
xackus has joined #zig
klltkr has joined #zig
klltkr_ has joined #zig
scientes has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]