ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
xackus has quit [Ping timeout: 246 seconds]
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> _ = try reader.read(user_input_slice);
<ask6155> const user_input_int = try parseInt(u8, user_input_slice, 10);
<ask6155> try writer.print("\n{}\n", .{user_input_slice});
<ikskuh> ah yes
<ikskuh> you're passing the whole buffer :D
<ikskuh> reader.read returns the number of bytes read
<ikskuh> so you need to do this:
<ikskuh> const len = try reader.read(&user_input);
<ikskuh> const user_input_slice = user_input[0..len];
<ikskuh> and pass that to parseInt
<ask6155> shouldn't parseint when to stop?
<ask6155> *know when to
<ikskuh> no
<ikskuh> why should it?
<ikskuh> is the "x" a digit? part of the content? excess?
<ikskuh> C assumes that and it's stupid and error prone
<ask6155> hmm
<squeek502> in other words, you're effectively telling parseInt that the input is 64 characters long (the length of your slice)
<squeek502> if your actual input is shorter, then you need to give it the appropriately sized slice
<ask6155> since my buffer was undefined at start... if i fill till x what will be there in x+1?
<squeek502> undefined
<ask6155> garbage?
<squeek502> most likely
<ikskuh> yes, garbage
<ask6155> okay so it makes sense now
<ask6155> also the slice has to be cut from 0..len-1 since read also counts the newline
<ikskuh> if you cut a slice, it uses these info:
<ikskuh> source[start_index_inclusive … end_index_exclusive]
<ikskuh> so you need to cut from [0..len] to get len chars
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
riba has joined #zig
knebulae has joined #zig
<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]
mht-technology is now known as mht
klltkr has quit [Quit: Textual IRC Client: www.textualapp.com]
Akuli has joined #zig
<ikskuh> marler8997: thanks for zigup btw :)
<marler8997> ikshuh, sure thing, at some point the goal will be to upstream it into the zig repo so everyone will just have it
<ikskuh> hehe, good idea :)
joey152 has joined #zig
scientes has joined #zig
joey152 has quit [Ping timeout: 272 seconds]
cole-h has joined #zig
Notimik has quit [Ping timeout: 260 seconds]
lanodan has quit [Read error: Connection reset by peer]
lanodan has joined #zig
scientes has quit [Read error: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac]
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
waleee-cl has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 256 seconds]
klltkr_ has quit [Ping timeout: 264 seconds]
ur5us has joined #zig
mattnite has joined #zig
<mattnite> hey everyone!
joey152 has joined #zig
Akuli has quit [Quit: Leaving]
<jjsullivan> mattnite, have a late hello :^)
a_chou has joined #zig
<mattnite> hi!
gpanders has quit [Ping timeout: 264 seconds]