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/
dermetfan has quit [Ping timeout: 272 seconds]
_whitelogger has joined #zig
<pixelherodev> ikskuh: wassup?
<pixelherodev> ikskuh: what did you want me to try?
nephele has quit [Read error: Connection reset by peer]
nephele_ has joined #zig
nephele_ is now known as nephele
satchmo has joined #zig
<satchmo> is there a way to initialize a File struct from the retval of syscallN()?
<pixelherodev> I mean
<pixelherodev> The file is just fd, right?
<pixelherodev> The only field you need to set is `handle`, which is a FD
<pixelherodev> If a syscall returns a FD, then `f = File { .handle = returned_value } ` should work
<satchmo> well File expects an i32 for .handle while syscallN() returns usize, so conversion doesn't exactly work out
<pixelherodev> Hmm
<pixelherodev> Check how open casts it?
daex has quit [Quit: /me 's znc kicks the bucket]
<pixelherodev> It uses std.os.open IIRC
<pixelherodev> Which also returns a usize, from a syscall?
<satchmo> os.open returns i32 :/
<pixelherodev> That makes no sense
<pixelherodev> Wait
<pixelherodev> What OS are you on?
<satchmo> linux
<pixelherodev> a FD is i32 on Linux, yeah
<pixelherodev> and open also returns usize
<pixelherodev> hmm
daex has joined #zig
<pixelherodev> It uses os.openatZ's return value
<pixelherodev> Okay
<pixelherodev> satchmo: just @intCast to std.os.fd_t
<pixelherodev> That's what std.os.openatZ does
<pixelherodev> You need to check the error value though
<pixelherodev> So I'd check if std.os supports what you want before doing it directly
<pixelherodev> e.g. `f = File { .handle = @intCast(std.os.fd_t, std.os.syscall(...) }`
<satchmo> :O, I think it worked
<pixelherodev> :)
<satchmo> thanks!
<pixelherodev> No problem :)
<pixelherodev> When in doubt, read the code ;)
<satchmo> ah, i see what I was doing wrong, was looking at os.zig instead of os/linux.zig..
<pixelherodev> :)
daex has quit [Ping timeout: 264 seconds]
daex has joined #zig
satchmo has quit [Quit: WeeChat 2.8]
knebulae has quit [Read error: Connection reset by peer]
craigo has joined #zig
knebulae has joined #zig
_whitelogger has joined #zig
ur5us has joined #zig
_whitelogger has joined #zig
benjif has quit [Ping timeout: 260 seconds]
ur5us has quit [Ping timeout: 260 seconds]
cole-h has quit [Quit: Goodbye]
aerona has quit [Quit: Leaving]
<pixelherodev> ?
<daurnimator> pixelherodev: its interesting
waleee-cl has quit [Quit: Connection closed for inactivity]
Tharro has quit [Quit: ZNC 1.7.4+deb0+bionic0 - https://znc.in]
Tharro has joined #zig
B4s1l3 has joined #zig
B4s1l3 is now known as opDispatch
_Vi has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
craigo has quit [Ping timeout: 265 seconds]
drp has quit [Ping timeout: 264 seconds]
dermetfan has joined #zig
drp has joined #zig
drp has quit [Quit: Leaving]
opDispatch has quit [Quit: Konversation terminated!]
swills has quit [Ping timeout: 256 seconds]
Tharro has quit [*.net *.split]
knebulae has quit [*.net *.split]
ifreund has quit [*.net *.split]
mikdusan has quit [*.net *.split]
cbarrett has quit [*.net *.split]
cncl has quit [*.net *.split]
alehander92 has quit [*.net *.split]
wjlroe has quit [*.net *.split]
l1x has quit [*.net *.split]
Cynthia has quit [*.net *.split]
kushalp has quit [*.net *.split]
tributarian has quit [*.net *.split]
lukeholder has quit [*.net *.split]
gonz_ has quit [*.net *.split]
lohengrin has quit [*.net *.split]
[RMS] has quit [*.net *.split]
commander has quit [*.net *.split]
ikskuh has quit [*.net *.split]
cow-orker has quit [*.net *.split]
Nilium has quit [*.net *.split]
jzelinskie has quit [*.net *.split]
euantor has quit [*.net *.split]
nikki93 has quit [*.net *.split]
_whitelogger has joined #zig
jjido has joined #zig
jjido has quit [Client Quit]
<Tharro> Trying to make a sprintf implementation but somehow the array (`buffer` in the sample code) is not copied when returned as a slice because the output is garbage: https://www.godbolt.org/z/UXJvPc Can somebody explain me which assumptions are wrong here?
<daurnimator> Tharro: sprintf8 returns a slice into the stack buffer `buffer` that is now stale
<daurnimator> Tharro: a slice is just a pointer and a length
<Tharro> Ok. Is there a way to transparently return an array of arbitrary length?
<daurnimator> Tharro: have caller pass in buffer or allocator
<Tharro> I've looked into the option of using an allocator but it seems there is no default/global allocator to allocate memory on the heap (e.g. the C malloc equivalent). Is that right?
<daurnimator> correct
<pixelherodev> I mean
<pixelherodev> std.heap.page_allocator does that
<pixelherodev> It's just not efficient
craigo has joined #zig
xackus has joined #zig
ask6155 has joined #zig
slowtyper has joined #zig
slowtype1 has quit [Ping timeout: 258 seconds]
dddddd has joined #zig
hermier has quit [Remote host closed the connection]
<ask6155> hey, I'm trying to build cmake but cmake .. gives error 'could not find clang (missing: CLANG_LIBRARIES)'
<ask6155> oops I'm trying to build zig
<ifreund> ask6155: zig needs to link against clang, llvm, and lld. do you have the development libaries/headers for all of these installed?
<ask6155> I have clang, lld, llvm, llvm-libs
<pixelherodev> Ugh
<ifreund> some distros split these into *-dev and normal packages, perhaps yours does that?
<pixelherodev> LLVM 10 problem, probably
<pixelherodev> Clang 10, rather
<pixelherodev> It's a PITA on a number of distros
<ifreund> but yeah could be that too https://github.com/ziglang/zig/issues/4799
<ifreund> my distro managed to package llvm10 in a non-broken way luckily
sarmonsiill has joined #zig
<ask6155> I use arch BTW
<ask6155> I requires the clang compiler, llvm and the linker, shouldn't that be it?
<ifreund> yeah they don't split -dev packages
<ifreund> i feel like someone on here mentioned that it worked fine on arch though
<daurnimator> ask6155: are you using: -DZIG_PREFER_CLANG_CPP_DYLIB=ON
<ask6155> no?
<daurnimator> try it then :)
<ifreund> hmm, didn't need that on void
<ask6155> ok it worked with that
<ask6155> I decided to use translate C on a C file and it says stdio.h not found
<daurnimator> ask6155: did you link libc?
<daurnimator> -lc
<daurnimator> i think that should work
<ask6155> why isn't that mentioned. Basically everyone links to libc
nycex- has quit [Remote host closed the connection]
<ask6155> I think I'm being a baby now
<pixelherodev> ask6155: Zig doesn't link libc by default
<pixelherodev> Because we're not C ;)
nycex has joined #zig
<daurnimator> we're trying to replace C here after all ;)
<ask6155> well translate-c needs to link to C so it should be made default
<pixelherodev> No it doesn't ;)
<pixelherodev> You can write C code w/o lib
<pixelherodev> libc*
<ask6155> ok...
ask6155 has quit [Quit: leaving]
hermier has joined #zig
arend has joined #zig
<arend> hello guys, how do you pass arguments to the binary using 'zig build run'?
wootehfoot has joined #zig
<ifreund> you can also just do ./zig-cache/bin/foobar
<arend> mikdusan but that doesnt work for me
<ifreund> odd, what are you trying to run?
<arend> nevermind
<arend> I removed the zig-cache folder and rebuilt
<arend> works now
<arend> thanks guys
DrDeano has joined #zig
<DrDeano> Hi, I am having some problems with ChildProcess where after I call `wait()`, I get a `OutOfMemory` but the error return trace says `PathAlreadyExists`
arend has quit [Remote host closed the connection]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
kristoff_it has joined #zig
sarmonsiill has quit [Remote host closed the connection]
sarmonsiill has joined #zig
Xavi92 has joined #zig
dingenskirchen has quit [Ping timeout: 256 seconds]
DrDeano has quit [Ping timeout: 245 seconds]
<ifreund> zig showtime starting in 5 min
DrDeano has joined #zig
dingenskirchen has joined #zig
idxu has quit [Ping timeout: 256 seconds]
<squeek502_> link to zig showtime btw: https://www.twitch.tv/kristoff_it
<squeek502_> starting in 3 mins
<THFKA4> CS 1.6 footsteps
fraktor has quit [Read error: Connection reset by peer]
aerona has joined #zig
craigo has quit [Ping timeout: 265 seconds]
decentpenguin has joined #zig
waleee-cl has joined #zig
dingenskirchen has quit [Remote host closed the connection]
frett27 has joined #zig
dingenskirchen has joined #zig
Akuli has joined #zig
<leeward> Are there any graphics libraries that don't depend on libc?
<pixelherodev> none that I'm aware of :(
<leeward> :/
kristoff_it has quit [Ping timeout: 265 seconds]
<ifreund> one downside of zig's lazy compliation is that code can stick around after a refactoring that never gets used
<ifreund> do we have a plan to combat this?
<ifreund> just found a function in my code that should have been deleted weeks ago
<Xavi92> ifreund: +1. Also I've found some functions that had different kind of errors but zig would not check them since they're lazily compiled
<leeward> I don't know of a plan, but something like `zig check` following all the comptime branches and noting dead code would certainly be useful.
<leeward> Of course, it would have to know to ignore libraries.
<ifreund> yeah a tool listing all the dead code would be a good start
<ifreund> even better would be a tool that tests all permuations of target and build options
jjido has joined #zig
<leeward> More important than just listing dead code, trying to compile branches not taken would expose errors.
jjido has quit [Client Quit]
<ifreund> yeah, that would be crazy useful for CI
<leeward> `if (someplatform) arr[17] else arr[2]` on an array with comptime known length of 3 won't fail unless someplatform is true.
aerona has quit [Quit: Leaving]
<leeward> Is there a new translate_c bug that's keeping SDL2/SDL.h from importing?
<ifreund> don't know, I'm not using sdl
<ifreund> also still on 0.6.0 :P
<leeward> heh
<leeward> Do you use any graphics libraries?
<ifreund> wlroots i guess
<ifreund> though it's a lot more than a graphics library
<ifreund> probably will need to though for some future wayland clients I'm planning on writing
<leeward> mm, would consider if I were using wayland
<ifreund> to be clear it's a library for wayland servers, not the average client :P
<ifreund> all the graphics I do is just compositing what the clients send and drawing it to the display
<ifreund> plus some borders and a background color
_Vi has joined #zig
jwmerrill has joined #zig
cole-h has joined #zig
<frett27> ifreund: +1, face the same, it seems a best practice to add a unit test, then it is compiled when run ?
jjido has joined #zig
<ifreund> frett27: yes, in an ideal world we wouldn't have this probelm as all code paths would be tested, however this is rarely the case in practice :)
<frett27> ifreund: yes, but from my experience this saves a lot of times to have a small test to check memory allocation, or dump parameters,
<frett27> ifreund: i must admit i don't have tests for all :-)
<ifreund> yeah, tests can save a ton of time
<ifreund> unfortunately writing tests for a wayland compsitor isn't all that easy and I have yet to look into how best to do it
<ifreund> probably need to write a bunch of test clients and some kind of testing framework
<frett27> ifreund: when compiling with build-obj, it should not strip symbols, is that a solution ?
<ifreund> I think weston has a fair bit of test coverage, I think I can take inspiration from there
waleee-cl has quit [Quit: Connection closed for inactivity]
<ifreund> frett27: not familar enough with how the compiler works to say
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waleee-cl has joined #zig
doublex has quit [Ping timeout: 260 seconds]
jjido has joined #zig
satchmo has joined #zig
gpanders has joined #zig
benjif has joined #zig
frmdstryr has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
r4pr0n has joined #zig
doublex has joined #zig
<jwmerrill> I'm working my way through the Zig cc blog post (https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html), and I'm a little confused about how it uses QEMU. At one point, it does `qemu-aarch64 ./src/luajit` to execute a command on the target. I've never used QEMU before, and I'm having trouble finding documentation on how to invoke QEMU like that.
_Vi has quit [Read error: Connection timed out]
<jwmerrill> I just installed QEMU through homebrew, and I see there's a binary called `qemu-system-aarch64` that can bring up an emulated machine, but I don't see how to get it to just run a single command like in the blog post.
jjido has joined #zig
<satchmo> I think you're referring to QEMU's user mode emulation
doublex_ has joined #zig
doublex has quit [Ping timeout: 264 seconds]
<jwmerrill> Oh, thanks. Maybe that isn't available through homebrew?
idxu has joined #zig
<satchmo> It looks like user mode is only for linux hosts
idxu has quit [Quit: ZNC - https://znc.in]
idxu has joined #zig
decentpenguin has quit [Quit: decentpenguin]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dingenskirchen1 has joined #zig
dingenskirchen has quit [Ping timeout: 256 seconds]
dingenskirchen1 is now known as dingenskirchen
sarmonsiill has quit [Ping timeout: 256 seconds]
doublex_ has quit [Ping timeout: 256 seconds]
_Vi has joined #zig
dermetfan has quit [Ping timeout: 256 seconds]
satchmo has quit [Quit: WeeChat 2.8]
dermetfan has joined #zig
BaroqueLarouche has quit [Ping timeout: 256 seconds]
doublex has joined #zig
<Xavi92> ifreund: BTW, is there any reason why zig does lazy compilation? Is it to achieve faster compilation speed?
alexnask has joined #zig
<ifreund> Xavi92: that, and it makes stuff like having differente dependencies based on a build option work
<ifreund> In C you would do this with macros, but with zig comptime is the way
<ikskuh> Xavi92: lazy compliation makes "not having a preprocessor" possible
<alexnask> This is the way
<ikskuh> and stuff like recursive data stuctures are also easier
<ifreund> yeah
jjido has joined #zig
<leeward> Xavi92: I think it's mainly about binary size. It only compiles the code that's used, even from the standard library.
jjido has quit [Client Quit]
<fengb> It’s a pervasive design philosophy. I’m not sure why it was chosen but things like OS features are completely dependent on it
<alexnask> ^
ur5us has joined #zig
Akuli has quit [Quit: Leaving]
<frmdstryr> Can I catch a whole error set in a switch?
<leeward> frmdstryr: You mean like `ErrorSet.FirstValue, ErrorSet.SecondValue =>`?
<frmdstryr> No like `ErrorSet =>` so i don't have to break each one out?
<leeward> Or do you want to check for membership in the error set with a single switch branch?
<frmdstryr> ^^ yes that
<leeward> I'm not sure, but I don't see an obvious way to do it. Looking through the builtins.
<leeward> I don't think switch will do it.
<leeward> I think I had this problem recently.
doublex has quit [Remote host closed the connection]
doublex has joined #zig
<leeward> Yep, the code I ended up with sidestepped it.
<alexnask> I tried writing a comptime ErrorDispatcher that did this at some point but Im pretty sure we need @Type(.ErrorSet) for it
<frmdstryr> I'm trying to reduce a global error set to a known error set so I can use streams but it doesn't seem to work. I have to catch and explicitly return each one...
<alexnask> Yes this is a weakness atm I think there was some github issue with a proposal that did something similar
<Xavi92> thank you all for your comments. I'm not so sure about the binary size reason: many C compilers separate symbols into their own sections so the linker removes unused code, but I don't know how the compilation process works in zig tbh
<alexnask> It would be pretty easy to do as a custom type with @Type(.ErrorSet) btw
<alexnask> s/btw/though
<leeward> Right, that's the thing, and it's not implemented yet.
<leeward> Xavi92: Yeah, you're probably right.
<alexnask> Yes as I said its a weakness atm
<leeward> Well, that's distracting. That's a large number of people walking down the street.
<alexnask> Not sure every linker eliminated dead code
<alexnask> Anyway just compiling what you need in the first place is less wasteful imo
<Xavi92> alexnask: surely not every linker, that's why I said "many"
<alexnask> zig uses lld atm btw (in the C++ compiler)
<Xavi92> alexnask: well, it ensures all code remains valid even if not used, but I understand why it was decided otherwise for zig
<fengb> In Zig, not all code is valid. OS features are implemented with this caveat
_Vi has quit [Remote host closed the connection]
<leeward> Oh hey, fengb, I've been meaning to ask: what do you use to draw on your wasm target?
<ifreund> to be clear, you need lazy evaluation to be able to do many things that would be enabled by a preprocessor in C
<ifreund> and a preprocessor has the same drawback of not compiling all the code
<leeward> It's true, C compilers won't complain about code that's #ifdef'd out. Even if it doesn't parse.
<ifreund> (among others)
<leeward> At least Zig code that isn't compiled still has to parse.
<ifreund> yeah
wootehfoot has quit [Read error: Connection reset by peer]
<frmdstryr> alexnask: Using @TypeOf(write).ReturnType.ErrorSet, thanks for the tip!
<Xavi92> sure
BaroqueLarouche has joined #zig
frett27 has quit [Ping timeout: 260 seconds]
pmwhite has quit [*.net *.split]
fengb has quit [*.net *.split]
AlexMax has quit [*.net *.split]
pmwhite has joined #zig
AlexMax has joined #zig
fengb has joined #zig
edr has quit [*.net *.split]
procnto has quit [*.net *.split]
utzig has quit [*.net *.split]
rappet has quit [*.net *.split]
AlexMax has quit [Max SendQ exceeded]
edr has joined #zig
procnto has joined #zig
utzig has joined #zig
rappet has joined #zig
DrDeano has quit [*.net *.split]
DrDeano has joined #zig
potta_coffee has quit [*.net *.split]
hspak has quit [*.net *.split]
WilhelmVonWeiner has quit [*.net *.split]
blueberrypie has quit [*.net *.split]
terinjokes has quit [*.net *.split]
potta_coffee has joined #zig
WilhelmVonWeiner has joined #zig
hspak has joined #zig
blueberrypie has joined #zig
terinjokes has joined #zig
potta_coffee has quit [Max SendQ exceeded]
ky0ko has quit [*.net *.split]
return0e[m] has quit [*.net *.split]
D3zmodos has quit [*.net *.split]
Bastian[m] has quit [*.net *.split]
sammich has quit [*.net *.split]
afontain_ has quit [*.net *.split]
rom1504 has quit [*.net *.split]
sammich has joined #zig
Bastian[m] has joined #zig
D3zmodos has joined #zig
afontain_ has joined #zig
ky0ko has joined #zig
return0e[m] has joined #zig
rom1504 has joined #zig
drewr has quit [*.net *.split]
zannzen[m] has quit [*.net *.split]
ifreund[m] has quit [*.net *.split]
Dominic[m] has quit [*.net *.split]
yawniek has quit [*.net *.split]
tdeo has quit [*.net *.split]
Snektron has quit [Ping timeout: 244 seconds]
metheflea has quit [Ping timeout: 244 seconds]
dtz has quit [Ping timeout: 246 seconds]
return0e[m] has quit [Ping timeout: 252 seconds]
D3zmodos has quit [Ping timeout: 252 seconds]
Bastian[m] has quit [Ping timeout: 252 seconds]
afontain_ has quit [Ping timeout: 252 seconds]
alva has quit [Ping timeout: 260 seconds]
hamoko[m] has quit [Ping timeout: 260 seconds]
<leeward> Anyone know if there's an easy way to turn a sentinel-terminated pointer into a slice?
factormystic has quit [*.net *.split]
dch has quit [*.net *.split]
bjornroberg has quit [*.net *.split]
mgxm has quit [*.net *.split]
jmiven has quit [*.net *.split]
dottedmag has quit [*.net *.split]
casaca has quit [*.net *.split]
torque has quit [*.net *.split]
Cadey has quit [*.net *.split]
shachaf has quit [*.net *.split]
tyler569 has quit [*.net *.split]
torque has joined #zig
dottedmag has joined #zig
mgxm has joined #zig
jmiven has joined #zig
bjornroberg has joined #zig
casaca has joined #zig
tyler569 has joined #zig
factormystic has joined #zig
shachaf has joined #zig
dch has joined #zig
Cadey has joined #zig
<alexnask> std.mem.spanZ I believe
m910q has quit [*.net *.split]
danyspin97 has quit [*.net *.split]
betawaffle has quit [*.net *.split]
scientes has quit [*.net *.split]
shodan45 has quit [*.net *.split]
nickster has quit [*.net *.split]
crimson_penguin has quit [*.net *.split]
yawniek has joined #zig
danyspin97 has joined #zig
m910q has joined #zig
betawaffle has joined #zig
shodan45 has joined #zig
scientes has joined #zig
nickster has joined #zig
crimson_penguin has joined #zig
tdeo has joined #zig
pmwhite has quit [Ping timeout: 244 seconds]
sammich has quit [Ping timeout: 252 seconds]
betawaffle has quit [Max SendQ exceeded]
fengb has quit [Ping timeout: 244 seconds]
xackus has quit [Ping timeout: 246 seconds]
BaroqueLarouche has quit [Ping timeout: 256 seconds]
betawaffle has joined #zig
BitPuffin has quit [Ping timeout: 272 seconds]
pltrz has quit [Ping timeout: 260 seconds]
nmeum has quit [Remote host closed the connection]
nmeum has joined #zig
<leeward> alexnask: yep, thanks
<leeward> Seems like span is just better than spanZ.
<leeward> er, other way around
<leeward> spanZ is safer.
Snektron has joined #zig
<Xavi92> oh, just realized I'm also having issue #5340
pmwhite has joined #zig
<Xavi92> I hope packed structs get fixed soon :)
<leeward> That would be nice.
fengb has joined #zig
BitPuffin has joined #zig
BaroqueLarouche has joined #zig
pltrz has joined #zig
hamoko[m] has joined #zig
D3zmodos has joined #zig
ifreund[m] has joined #zig
alva has joined #zig
AlexMax has joined #zig
sammich has joined #zig
afontain_ has joined #zig
return0e[m] has joined #zig
drewr has joined #zig
metheflea has joined #zig
dtz has joined #zig
Xavi92 has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
Bastian[m] has joined #zig
Dominic[m] has joined #zig
mokafolio has quit [Read error: Connection reset by peer]
moka has joined #zig
moka is now known as mokafolio
craigo has joined #zig
<fengb> leeward: manual conversion to canvas atm: https://github.com/fengb/fundude/blob/master/web/Display.tsx#L87
<fengb> Still debating whether to make the data match canvas output, in which case that’d be a simple-ish memcpy
<leeward> fengb: thanks, and...oof
<fengb> The raw code is nicer. Those magic numbers are from LLVM that seemed to help performance
<fengb> The data format is raw Gameboy Color values
<leeward> Wait, what's this for (let i = 0; i < pixels.length; i++) thing? Did Zig get C's for loops?
<fengb> No this is all JS
<leeward> ohhhh
<fengb> You can’t do web stuff in wasm so the glue must be in JS
<leeward> That makes way more sense now.
<leeward> Also makes me a bit more sad, but that's JS for you.
mikdusan1 has joined #zig
mikdusan has quit [Ping timeout: 265 seconds]
dermetfan has quit [Ping timeout: 256 seconds]
DrDeano has quit [Ping timeout: 245 seconds]