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/
ky0ko_ has joined #zig
ggVGc has quit [Ping timeout: 272 seconds]
<smolck> alright, later y'all; thanks again so much for the help ikskuh
smolck has left #zig [#zig]
xackus has quit [Ping timeout: 246 seconds]
<cr1901_modern> How do I pass a string literal to a function accepting a []u8?
<cr1901_modern> Okay I see... without "const" qualifier I can
<cr1901_modern> 't pass a string into a function accepting a slice (even though that is what I want)
<cr1901_modern> ehh, I'll make it const anyway :)
_Vi has quit [Ping timeout: 244 seconds]
traviss__ has joined #zig
traviss_ has quit [Ping timeout: 265 seconds]
nephele_ has joined #zig
nephele has quit [Ping timeout: 260 seconds]
nephele_ is now known as nephele
cole-h has joined #zig
a_chou has joined #zig
decentpenguin has joined #zig
xd1le has quit [Read error: Connection reset by peer]
xd1le has joined #zig
ur5us_ has joined #zig
xd1le has quit [Remote host closed the connection]
xd1le has joined #zig
marnix has joined #zig
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
ur5us_ has quit [Ping timeout: 260 seconds]
_whitelogger has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
a_chou has quit [Quit: a_chou]
_whitelogger has joined #zig
dec05eba has joined #zig
cole-h has quit [Quit: Goodbye]
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
omglasers2 has joined #zig
brotein has joined #zig
brotein has quit [Quit: leaving]
<ifreund> cr1901_modern: for future reference, you can create a mutable buffer containing a string like so: var buf = "hello".*;
<ifreund> and then pass &buf to your function taking a []u8
_whitelogger has joined #zig
ur5us_ has joined #zig
marnix has joined #zig
jasom has quit [Ping timeout: 244 seconds]
jasom has joined #zig
gpanders has quit [Quit: ZNC - https://znc.in]
gpanders has joined #zig
xackus has joined #zig
omglasers2 has quit [*.net *.split]
alva has quit [*.net *.split]
Nypsie[m] has quit [*.net *.split]
l1x has quit [*.net *.split]
Cadey has quit [*.net *.split]
omglasers2 has joined #zig
alva has joined #zig
Nypsie[m] has joined #zig
l1x has joined #zig
Cadey has joined #zig
riba has joined #zig
ur5us_ has quit [Ping timeout: 260 seconds]
riba has quit [Ping timeout: 260 seconds]
_Vi has joined #zig
riba has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
starhopper has joined #zig
<starhopper> Is a local array still valid outside the function it's declared in? I allocated a local array in function and returned the address of it, and it seems that the address is still valid outside of the declaring function, which is strange.
<ikskuh> starhopper: the address is still valid, but the data it's pointing to is not
<ikskuh> it's not allowed to return a pointer-to-local
<ikskuh> you can return the array as a object though:
<ikskuh> fn foo() [3]u8 {}
<starhopper> But the code is working all fine?
<starhopper> So it'll blow up someday, right?
<ikskuh> yep
<starhopper> Also, why doesn't the Zig compiler give me an error?
<ikskuh> because it cannot detect that yet
<starhopper> Okay, got it. Thanks!
<starhopper> One more thing: does anybody know when packed structs are gonna be fixed?
<starhopper> Embedding a packed struct in another packed struct makes the Zig compiler segfault.
<ikskuh> probably with stage2
shodan45 has quit [Quit: No Ping reply in 180 seconds.]
<Nypsie[m]> I think it will be fixed in stage 2 itself as it's not a requirement to build stage 2 I don't think it will be fixed in stage 1. So probably 0.8.0 latest I guess
<starhopper> So right now I have to pray that the struct is laid out in order of declaration.
<ikskuh> starhopper: you can also use extern structs
riba has quit [Ping timeout: 258 seconds]
<ikskuh> they are sufficient for most of the cases
<starhopper> How?
<starhopper> I just replace packed with extern, right?
<starhopper> "An extern struct has in-memory layout guaranteed to match the C ABI for the target."
<ikskuh> yep
<starhopper> "Unlike normal structs, packed structs have guaranteed in-memory layout"
<starhopper> What's the difference?
<ikskuh> yeah, extern have also guaranteed layout
<ikskuh> packed struct has 0 bit padding
<starhopper> Oh
<ikskuh> extern structs might have padding
<starhopper> Right, thanks again.
<ikskuh> so @bitSizeOf(packed struct { a: u3, b: u5 }) == 8
<ikskuh> what do you need guaranteed order though?
<starhopper> Passing structs to C code
<starhopper> It's for an Opengl program.
<ikskuh> ah
<ikskuh> OpenGL vertex data?
<starhopper> Yeah
<ikskuh> oh
<ikskuh> you don't need any guaranteed layout for that! :)
<starhopper> Whahh?
<ikskuh> yep
<ikskuh> zig == awesome
<ikskuh> give me a second
<ikskuh> vao.attribFormat(0, 3, .float, false, @byteOffsetOf(Vertex, "position"));
<ikskuh> just use @byteOffsetOf :)
<starhopper> Oh, right
<starhopper> Let Zig calculate the offsets
<starhopper> Awesome
<ikskuh> what i really like about zig default structs:
starhopper has left #zig [#zig]
<ikskuh> the compiler might chose different layouts for different compile modes
starhopper has joined #zig
<ikskuh> <ikskuh> the compiler might chose different layouts for different compile modes
<ikskuh> which means: release-small might use packed structs for every non-extern struct
<starhopper> Yeah, that was a nice decision.
<ikskuh> also reordering fields to make smaller structs without alignment violation
starhopper has quit [Remote host closed the connection]
wootehfoot has joined #zig
xd1le has quit [Remote host closed the connection]
xd1le has joined #zig
DarkPlutonium has joined #zig
DarkUranium has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
xd1le has quit [Read error: Connection reset by peer]
frett27 has joined #zig
xd1le has joined #zig
<frett27> hi, i got an optional pointer in a struct, how can i test the optional ? using if (s.optionalmember) |thepointer| { /* here i got 0xaaaaaa in the pointer */} don't work as the value of the optional is 0xaaaaaaaaaaa
<frett27> may be the value as not been initialized
<Nypsie[m]> Correct, 0xaaaaaa is the value given to undefined values in debug mode
<frett27> it works, using the initialization ! thank's Nypsie
<Nypsie[m]> Yay :) No problem
wootehfoot has quit [Read error: Connection reset by peer]
omglasers2 has quit [Quit: Leaving]
waleee-cl has joined #zig
isolier has joined #zig
wootehfoot has joined #zig
klltkr has joined #zig
CommunistWolf has quit [Ping timeout: 244 seconds]
CommunistWolf has joined #zig
CommunistWolf has quit [Ping timeout: 244 seconds]
CommunistWolf has joined #zig
CommunistWolf has quit [Excess Flood]
CommunistWolf has joined #zig
cole-h has joined #zig
haliucinas has quit [Remote host closed the connection]
CommunistWolf has quit [Ping timeout: 244 seconds]
haliucinas has joined #zig
CommunistWolf has joined #zig
CommunistWolf has quit [Excess Flood]
CommunistWolf has joined #zig
brotein has joined #zig
<brotein> ls
<ifreund> .
<ifreund> ..
<brotein> oops :)
<brotein> wrong terminal
CommunistWolf has quit [Ping timeout: 260 seconds]
CommunistWolf has joined #zig
<brotein> is this irc channel as lively as discord?
<ifreund> it's a little lower traffic i guess but quite active as IRC channels go
CommunistWolf has quit [Excess Flood]
CommunistWolf has joined #zig
<fengb> Tends to be more on topic here :P
<ifreund> you also have a different demographic
<brotein> yeah, I hear that's why some people love irc, because it filters out some people, I guess
<ifreund> for me it's not as much about who is filtered out as about who is here
CommunistWolf has quit [Excess Flood]
<brotein> you mean that some people only use irc and not discord
<ifreund> yes
<brotein> ok, good to know
<brotein> I am compiling the zig0 compiler, and to do that I am compiling llvm. I somehow used the 10.0.1 branch of llvm and I got some linking errors when compiling zig
<brotein> and I just saw on the wiki the llvm version should be 10.0.0
<brotein> so I am compiling that now, I am just surprised llvm would make breaking changes between those two versions
<brotein> I thought I could use them interchangeably
<brotein> naively
<ifreund> I think it should work with 10.0.1, and I seem to recall testing that on arch when 10.0.1 was released
<brotein> it is not to be excluded that's on me :D
<ifreund> well, I have yet to compile llvm myself, always just used a version from my distro's repos
<ifreund> so I'm not sure what footguns are lurking there that could break thins
<brotein> I have tried previously to install llvm-dev through the system package manager, so maybe it interfered. Now I have removed it to be sure.
WilhelmVonWeiner has joined #zig
<ifreund> what distro?
kwilczynski has quit []
<brotein> alpine
<ifreund> they have an llvm10 package no?
<ifreund> shouldn't really need to build it yourself
<brotein> I thought so but the cmake step to build zig failed, complaining about llvm stuff
<ifreund> perhaps you need -DZIG_PREFER_CLANG_CPP_DYLIB=ON with how their llvm package is set up
<brotein> I think it said llvm was not built with all architectures that zig needs, but I am not 100% sure because I tried to do the same yesterday on openbsd and into errors there as well
<brotein> so I might confuse the two
<brotein> got into errors*
<ifreund> or maybe not, they don't seem to pass it here: https://git.alpinelinux.org/aports/tree/testing/zig/APKBUILD
<brotein> right, so just to be sure I did it again: apk add llvm10-dev clang-dev lld-dev
<brotein> then in the zig repo: `cmake ..; make`
<ifreund> that APKBUILD list quite a few other packages in the makedepends
<brotein> and I get linking errors
<ifreund> do you have them all?
<brotein> oh great, I just opened the link
<brotein> thanks!
<ifreund> np
<brotein> I am compiling zig again, let's see
<ifreund> alpine does go farther than most when it comes to splitting packages :P
<brotein> good to know, I just installed it as a desktop for my home computer, let's see how it goes :)
msingle has joined #zig
kwilczynski has joined #zig
Akuli has joined #zig
wootehfoot has quit [Quit: Leaving]
msingle has quit [Ping timeout: 260 seconds]
nullheroes has quit [Quit: WeeChat 2.9]
nullheroes has joined #zig
isolier has quit [Quit: isolier]
wootehfoot has joined #zig
isolier has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 240 seconds]
the-oaks has joined #zig
omglasers2 has joined #zig
the-oaks has quit [Client Quit]
the-oaks has joined #zig
the-oaks has quit [Client Quit]
the-oaks has joined #zig
the-oaks has quit [Client Quit]
_Vi has quit [Ping timeout: 244 seconds]
<frett27> i have a ubuntu package list to build zig from source, and avoid recompiling the llvm stuff, if it can help
<frett27> don't know if these are the same packages for alpine
<brotein> interesting, thanks
<brotein> I am having both with apk packages and with llvm built from source issues when compiling zig from source
<brotein> I get lots of linking errors such as: zig_clang_cc1_main.cpp:(.text._ZN4llvm24InitializeAllAsmPrintersEv[_ZN4llvm24InitializeAllAsmPrintersEv]+0x55): undefined reference to `LLVMInitializeAVRAsmPrinter'
<brotein> my guess is that there is a version mismatch between the llvm libs I have built and installed, and the ones zig expects
<brotein> it is weird since `nm` shows the right symbols in the lllvm libs installed in /usr/local/libs
<brotein> oh well
frett27_ has joined #zig
frett27 has quit [Ping timeout: 264 seconds]
metabulation has joined #zig
<frett27_> brotein, i've not tested on 10.0.1, only 10.0.0
<frett27_> and for ubuntu i faced the polyfill link error
<frett27_> that has been solved
<brotein> ok, thanks
cr1901_modern has quit [Ping timeout: 246 seconds]
<brotein> I'll try tomorrow again with a fresh mind, in the meantime I am using the binary from the zig website
wootehfoot has quit [Ping timeout: 256 seconds]
st4ll1 has quit [Quit: WeeChat 2.9]
_Vi has joined #zig
brotein has quit [Remote host closed the connection]
cr1901_modern has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
yawniek has quit [Ping timeout: 260 seconds]
frett27_ has quit [Ping timeout: 240 seconds]
yawniek has joined #zig
st4ll1 has joined #zig
<omglasers2> how does readUntilDelimiterOrEof work? I'm trying to read line by line from stdin but it returns the input until EOF, not after every line (I'm on windows)
ur5us has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
metabulation has quit [Read error: Connection reset by peer]
cole-h has quit [Quit: Goodbye]
marnix has quit [Ping timeout: 240 seconds]
xackus has quit [Ping timeout: 246 seconds]
ur5us has quit [Ping timeout: 256 seconds]
CommunistWolf has joined #zig
ur5us has joined #zig
Akuli has quit [Quit: Leaving]
omglasers2 has quit [Quit: Leaving]
zippoh has joined #zig
DarkPlutonium is now known as DarkUranium
<andrewrk> Cadey, afaik the only dependency of std on /dev is /dev/null. We try not to add undue dependencies like this, but it's needed for some cases, such as ignoring child process streams. what are you running into?
omglasers2 has joined #zig
omglasers2 has quit [Client Quit]
smolck has joined #zig
<smolck> hello! is it possible to check if a type is an anonymous struct? i.e. do something like @TypeOf(.{}) == struct?
<andrewrk> ikskuh, https://ashet.computer/ shows me a certificate error
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
<smolck> andrewrk, thank you, but I'm having trouble using that with a switch statement on a comptime T: type. What I'm trying to do is handle the case of annonymous structs being passed in to my function, so things like .{false, true}, .{"hello", 5}, etc., and I want to know how I can see if the item passed in is any kind of anonymous struct. I've tried using @typeInfo, @hasField, etc., but I can't seem to figure it
<smolck> out
<smolck> (hope that makes sense)
<andrewrk> it's pretty meta to need to check that. why do you need to make that distinction? you can't just use the fields?
<smolck> hmm, maybe I'm going about this wrong then, I'm trying to implement a msgpack serializer/deserializer (see https://github.com/msgpack/msgpack/blob/master/spec.md) and I'd like to handle cases like .{"hello", 56, .{1, 2, 3}}
<smolck> so I can handle the basic types, but I'm having trouble with the struct part
<andrewrk> hmmm. I'm actually not the best person to ask about meta programming and so I'll be quiet to let other folks chime in :)
<andrewrk> I'm biased against it ;)
<smolck> okay cool, just explaining this I'll probably figure it out ;)
cr1901_modern has quit [Ping timeout: 240 seconds]
<pixelherodev> Making very good progress on spu_2 backend :)
cr1901_modern has joined #zig
<pixelherodev> Parameters should be finished tomorrow, along with basic arithmetic and a bit more :D
<smolck> is there a way to convert "bool" -> bool (the type), and similar for other types?
<smolck> (i.e. get the type if all you have is @typeName(x))
<pixelherodev> smolck: is the string comptime known?
<smolck> yes, it should be
<smolck> (actually at this point I don't think I need to do that after all, but now I'm still curious how it's done)
st4ll1 has quit [Ping timeout: 240 seconds]
<pixelherodev> smolck: with comptime strings, just do a `std.mem.eql`
<pixelherodev> Types are first-class at comptime
<smolck> oh gotcha
<smolck> thank you