ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
<MajorLag> is freebsd CI broken or is it just me?
hooo has quit [Quit: Connection closed for inactivity]
<andrewrk> MajorLag, I think you need to merge master or rebase your PR to fix it
<MajorLag> alright, not a big deal yet since fixing c_allocator didn't fix whatever is causing the failure in the other CIs, but that one had always passed so I was curious.
Szwagi has joined #zig
<Szwagi> I'm interested in ziglang, am I in the right place?
<Szwagi> Right, there's a big header saying it is lol
adrusi_ has joined #zig
adrusi has quit [Ping timeout: 250 seconds]
<wilsonk> Szwagi: lol, yes you are in the right place. Welcome! :)
Szwagi has quit [Quit: Page closed]
_whitelogger has quit [Ping timeout: 250 seconds]
_whitelogger has joined #zig
kristate has joined #zig
kristate has quit [Ping timeout: 244 seconds]
Szwagi has joined #zig
<Szwagi> Soo.. I'm new to the language, trying to learn via writing some code and reading the documentation. What is the best approach to allocate a singular object on the heap via an allocator?
<Szwagi> From what I can tell, allocFn returns a []u8 and alloc returns []T. Came up with this -> var window = &(try allocator.alloc(Window, 1))[0];
<Szwagi> but it seems kinda hacky (?)
<daurnimator> Szwagi: .createOne
<daurnimator> (I actually use .create.... but I see that now has a deprecation notice. anyone know why?)
raoof has joined #zig
forgot-password has joined #zig
<forgot-password> Hi guys, I'm having trouble with the c interop again. I have a function that returns an optional pointer to a c struct, which I unwrap via orelse. If, however, I try to access any fields of that struct I get 'type [*]const T does not support field access'. Why is that? Does Zig fail to read the struct structure (no pun intended) in that case?
<daurnimator> forgot-password: you have an array there. you need to pick a member first
<forgot-password> Oh my god, how could I be that dense. I even have the c declaration right in front of me. Thank you, daurnimator :)
<forgot-password> Is there a way to automatically unwrap the first element of my optional pointer or do I *have to* go through a separate variable?
<daurnimator> forgot-password: huh? shouldn't it just be a case of adding [0] to your one-liner?
<forgot-password> Right, I can just put it in parens. Maybe I should get something to eat before I continue ^^
kristate has joined #zig
<daurnimator> forgot-password: or edit the generated zig to change [*] to plain *
<daurnimator> forgot-password: or wait for :P
_whitelogger has joined #zig
<Szwagi> How would I go about converting a zig-string to a c-string? Is there anything to help me with that in the stdlib?
<kristate> Szwagi: is the zig string constant or runtime?
<Szwagi> would be nice if it was able to convert both
<kristate> Szwagi: if it's constant, you can simply use ++ like so: a_constant_str ++ []u8{0}
<kristate> Szwagi: and then ptrcast to c-string, @ptrCast([*]const u8, a_constant_str ++ []u8{0})
raoof has quit [Ping timeout: 256 seconds]
Zaab1t has joined #zig
<Szwagi> Managed to do something with only a few hours worth of experience with the language:
<Szwagi> :D
<daurnimator> Szwagi: you may want `packed struct`
<Szwagi> thanks, fixed
<daurnimator> Szwagi: re line 134, you can do something like: `instance: if (builtin.os == HINSTANCE else void`
<daurnimator> Szwagi: your errdefer at line 209 seems pointless?
<Szwagi> it is, but i dont think the compiler will do anything with it anyway so it's there in case i put in some code there in the future
<daurnimator> Szwagi: btw, I don't recall if `extern struct` is prefered over `packed struct`
<daurnimator> Szwagi: otherwise, you should send a PR to zig to add those windows structs/defines you translated :)
<Szwagi> packed struct makes the program crash, so i'm guessing it's extern struct I need
Szwagi has quit [Quit: Page closed]
<kristate> use `extern struct` for C ABI compatibility
<daurnimator> kristate: k. seems to not be documented.
<daurnimator> though I find it in generated source and the standard library
<daurnimator> wasn't sure if it was deprecated or new
<kristate> daurnimator: yes, it's on the TODO for 0.4.0
shollrollah951 has joined #zig
steveno_ has joined #zig
hgctl has joined #zig
forgot-password has quit [Ping timeout: 250 seconds]
forgot-password has joined #zig
Ichorio has joined #zig
forgot-password has quit [Quit: leaving]
steveno_ has quit [Ping timeout: 250 seconds]
steveno_ has joined #zig
MajorLag has quit [Ping timeout: 252 seconds]
MajorLag has joined #zig
knebulae has quit [Quit: Leaving]
hooo has joined #zig
steveno_ has quit [Quit: Leaving]
hgctl has quit [Quit: WeeChat 2.3]
Zaab1t has quit [Quit: bye bye friends]
shollrollah951 has quit [Quit: Leaving]
MajorLag has left #zig [#zig]
kristate has quit [Remote host closed the connection]