<marijnfs>
true the loop over fields is comptime i guess. I mean the infinite loop is then at runtime.
<marijnfs>
msg is a c-type, but could be removed for the example
ur5us_ has quit [Ping timeout: 264 seconds]
<marijnfs>
this comptime loop was needed to find the right union, not sure if there is a better way to do it now?
arielp has joined #zig
zags has quit [Ping timeout: 256 seconds]
notzmv has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
ur5us_ has joined #zig
arielp has left #zig ["WeeChat 3.0.1"]
leon-p has quit [Quit: leaving]
notzmv has quit [Ping timeout: 256 seconds]
marijnfs has quit [Quit: WeeChat 2.8]
dfacto has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 276 seconds]
earnestly has quit [Ping timeout: 245 seconds]
brzg has joined #zig
craigo has joined #zig
powerofzero has quit [Ping timeout: 264 seconds]
powerofzero has joined #zig
Techcable has quit [Quit: Techcable - The Lounge]
arwn has joined #zig
Techcable has joined #zig
<arwn>
Hey I want to sort an array of `card = struct{rank:i32, suit:i32}`'s how do i create a custom compare function so i can pass it to std.sort.sort()?
<g-w1>
you mean lessThan?
<brzg>
just make an `fn cardLt(ctx: void, a: card, b: card) bool`, which returns true if card a should be considered less than card b
<brzg>
then pass .{} for context and cardLt for lessThan when calling sort
<g-w1>
dont pass .{} just pass {}
<g-w1>
{} is a value of type void
eax has joined #zig
<arwn>
alright i'll try that, thanks.
texno has quit [Ping timeout: 260 seconds]
hspak has quit [Quit: bye]
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
hspak has joined #zig
texno has joined #zig
earnestly has joined #zig
<arwn>
very cool, it works. if I wanted to figure out what `context` was for where would I go? the ziglang docs don't seem to explain it.
<g-w1>
context is probably what you pass to the compare function
<brzg>
it's in case you'd need data to handle the comparison beyond just the two items to compare
eax has quit [Remote host closed the connection]
notzmv has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
brzg has quit [Quit: leaving]
<arwn>
Is there a way to loop over an enum other than converting the last element to an int?
<g-w1>
loop over in what way?
<arwn>
I want to generate a deck of cards. i have two enums representing suit and rank. I want to have two nested for loops that generate every card. like `for (suit in suit) { for rank in rank } append(cards, Card{suit, rank})}} or something.`
<arwn>
my curly braces are wrong but hopefully you get the idea.
powerofzero has quit [Ping timeout: 245 seconds]
<g-w1>
hmm, you can try to use std.meta.fields and iterate through them
<tnorth>
Hey there. I'm trying to debug a Zig program with GDB. I have a struct (foo) with a member bar = ?[]@This(). When breaking in GDB after intialization (bar is allocated with a c_allocator) and printing foo, I get: $1 = {bar = <error reading variable>}. Printing foo.bar says: "That operation is not available on integers of more than 8 bytes". Moreover, I can't index it (print foo.bar[0] for instance). Is that normal? Is
<tnorth>
there a workaround?
<ikskuh>
what about foo.bar.ptr ?
<tnorth>
ikskuh: "There is no member named ptr"
<tnorth>
I expected GDB to find the address to the beginning of bar
<Raito_Bezarius>
has getEnvPosix disappeared in the std.os namespace?
<Raito_Bezarius>
If so, is the canonical way to read from env vars to allocate something?
haliucinas has quit [Read error: Connection reset by peer]
haliucinas has joined #zig
clee has joined #zig
<clee>
having trouble figuring out how to do something pretty basic; using zig 0.6.0, how do I open an absolute path as a directory and walk all of its subpaths?
<txdv>
raylib + zig is so simple, easy and fun to use, it should be on the zig playground as one of the default examples
zags_ has quit [Ping timeout: 276 seconds]
notzmv has quit [Ping timeout: 260 seconds]
ur5us_ has joined #zig
<andrewrk>
what zig playground are you referring to?
<andrewrk>
mikdusan, thanks for looking into zig-bootstrap/macos/CI stuff. hmm so did we regress with llvm12? I think we do use zig-bootstrap for macos CI right now
txdv has quit [Quit: Connection closed]
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #zig
<andrewrk>
ah right, so what we do is use `zig cc` and `zig c++` only, to build zig, on macos. I think that will still work fine with llvm12, right?
sord937 has quit [Quit: sord937]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
powerofzero has quit [Remote host closed the connection]
powerofzero has joined #zig
Akuli has left #zig ["Leaving"]
zags has joined #zig
Akuli has joined #zig
<s-ol>
how does package resolution work for @import()?
Akuli has quit [Quit: Leaving]
<s-ol>
ah, i found build.Pkg.dependencies, which does what I need :)
notzmv has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
dddddd has joined #zig
xackus has joined #zig
xackus_ has quit [Ping timeout: 264 seconds]
texno has quit [Ping timeout: 246 seconds]
tane has quit [Quit: Leaving]
<Raito_Bezarius>
can we deep initialize a struct?
<Raito_Bezarius>
inst = A { .subinst = B { .x = 0, .y = 1 } }
<Raito_Bezarius>
something like that
<Raito_Bezarius>
nevermind, I was doing something wrong