ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Read error: Connection reset by peer]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
<presiden>
just realize that the syntac for struct is changed, in 0.3 it's struct { ... } but in master it's sturct.{ ... }
<presiden>
is there a post/issue about this change?
<DutchGh0st>
I am using Windows, maybe that is it?
<DutchGh0st>
altough os.File doesnt care about platform per se,
<andrewrk>
DutchGh0st, it works on master branch for both linux and windows. I'm guessing you're using an older version of zig which had a different std lib API
<DutchGh0st>
and that combination of print, read is done like 8 times
<DutchGh0st>
isn't there a function like io.readline, but that takes already acquired stdin handle?
<andrewrk>
DutchGh0st, that's a good point, there should be one
<andrewrk>
and then std.io.readLine should call it
<DutchGh0st>
I dont know how expensive it is to acquire stdin, but I feel like calling io.readline over and over again has more overhead than needed
<DutchGh0st>
and maybe there's also an io.writeLine currently? perhaps a similar function should be added as well
<DutchGh0st>
I can make a proposal right now, and see what everyone thinks of it? :)
jjido has quit [Ping timeout: 252 seconds]
jjido has joined #zig
jjido has quit [Ping timeout: 250 seconds]
<andrewrk>
I don't think we need io.writeLine. the normal stream API should suffice
<andrewrk>
readLine exists because it makes sense to do when treating stdin as a "terminal ui" sort of thing
<andrewrk>
e.g. it would make sense for it to use escape codes and such
<jfondren>
how can I avoid the struct initialization here? https://gist.github.com/jrfondren/cd396d2c156e46d4ac4d73ea55a067e8 I just want to stack-allocate however much the struct needs (especially without caring about stuff like __reserved) and then let the function initialize it
<andrewrk>
jfondren, var usage: c.struct_rusage = undefined;
<andrewrk>
are you trying to produce a linux binary or a macos binary?
<andrewrk>
on macos, applications always link libSystem (which is libc) because that's the stable syscall ABI
<andrewrk>
I don't think it would make sense to use musl
<jfondren>
I'm not actually using musl. Just using its header, since zig can't find sys/resource.h otherwise
<andrewrk>
where is sys/resource.h on your system?
<nbjoerg>
the fun of modern glibc deployments where they vomit headers in random places?
<jfondren>
= undefined does work... I must've tried that only when there were other problems, and never tried it again.
<jfondren>
macOS Mojave has a bunch of sys/resource.h files under different X.platform dirctores under /Applications/Xcode.app
<andrewrk>
is that 10.14?
<jfondren>
so, probably the technically correct one is /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h
<andrewrk>
what we need to figure out is, how does the native system compiler know to look there
<jfondren>
10.14 aye
<andrewrk>
on linux we do: `cc -E -x c - -v` and that gives us the include dir
<andrewrk>
on macos it doesn't work
<nbjoerg>
it doesn't?
<andrewrk>
looks like I can upgrade my laptop from 10.13.6 -> 10.14.1
<andrewrk>
I'll try it
<andrewrk>
jfondren, you could also send a patch to the std lib that adds getrusage extern declaration in std/c/darwin.zig (or if it's a posix api, in the main file)
<andrewrk>
and then while waiting for the patch to be merged, just have the extern declaration local to your project
<andrewrk>
a good start would be `zig translate-c /path/to/sys/resource.h` and then clean up the pointer types and add "c" to the `extern` decls
<andrewrk>
this would remove a dependency on /usr/local/Cellar/musl-cross/* in your project
<jfondren>
it's a POSIX API. Although I notice that the units change across OSes (RSS is in bytes, not kB, on macOS)
<jfondren>
sure, I'll take a look at that
<andrewrk>
jfondren, one more thing, looks like you're making a CLI app whose purpose is to output information right? so you probably want to output to stdout rather than using std.debug.warn