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"
<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>
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?
<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 :)