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/
fengb has quit [Ping timeout: 256 seconds]
<daurnimator> nrdmn: copy into what?
<daurnimator> nrdmn: b.* = a.*; // if you have e.g. two pointers
hio has quit [Quit: Connection closed for inactivity]
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 248 seconds]
heitzmann has quit [Ping timeout: 248 seconds]
heitzmann has joined #zig
fengb has joined #zig
coolreader18 has quit [Ping timeout: 246 seconds]
heitzmann has quit [Ping timeout: 257 seconds]
heitzmann has joined #zig
jevinskie has joined #zig
heitzmann has quit [Ping timeout: 258 seconds]
heitzmann has joined #zig
<merlyndmg> is there a way to convert from [*c]u8 to []u8? I know the length
<daurnimator> merlyndmg: slice it
<daurnimator> merlyndmg: i.e. [0..knownlen]
<merlyndmg> thx!
jevinskie has quit [Quit: Textual IRC Client: www.textualapp.com]
coolreader18 has joined #zig
<andrewrk> tgschultz, I wsa thinking along similar lines
<tgschultz> it's nice to know I'm not just off in the woods somewhere, that happens too often.
<daurnimator> andrewrk: have you signed up for http://github.com/sponsors ?
<daurnimator> andrewrk: also, what are you working on? :)
<andrewrk> daurnimator, yes I'm on the wait list. I'm working on https://github.com/ziglang/zig/pull/2527
<andrewrk> I'm about to break a lot of stuff, want to make sure I do it right
<daurnimator> andrewrk: I think you might be making a few mistakes with the current draft PR
<andrewrk> daurnimator, let me push my changes from today and you can provide some review comments
<daurnimator> e.g. IMO, "os/linux/posix" doesn't make sense. -> there should be os/linux/* that contains direct bindings to linux things. And then there should be os/posix/linux.zig, which would implement posix (and yes *only* things defined in posix; not all the little extras) on top of os/linux
<andrewrk> sounds like your disagreement is only with the naming convention?
<daurnimator> andrewrk: I don't think so. e.g. why is `pub const SYS_read = 0;` under os/linux/posix? SYS_read doesn't have anything to do with posix
<merlyndmg> I don't know if it's desired, but I've created a pull request to switch from libpng+zlib to stb_image for the tetris demo. It made it easier to get it working on windows, and simplified the loading code a tiny bit: https://github.com/andrewrk/tetris/pull/18
<andrewrk> merlyndmg, nice, that's a good improvement!
<andrewrk> daurnimator, on linux SYS_read is in the same namespace as all the posix libc stuff
<andrewrk> it's the same abstraction layer, just linux specific
<daurnimator> andrewrk: but that's linux libc convention. which is something I don't even think we should have!
<daurnimator> IMO there are 3 layers of interest: 'low level' (actual syscall ABI), 'posix' (POSIX defined portable bits), 'zig specific' (high level wrappers like std/fs that take advantage of whatever is best for the platform)
<andrewrk> daurnimator, I pushed my changes from today - feel free to make specific suggestions about how to rename/move stuff
<andrewrk> I agree that those are the layers
<andrewrk> with my recent changes SYS_read can move to be private to the syscall wrappers file
<daurnimator> andrewrk: why private?
<daurnimator> andrewrk: also, what would you think of defining e.g. syscalls as an enum?
<daurnimator> andrewrk: hrm. reviewing the PR... it's really hard to figure out where to put design comments. github wants me to associate with specific lines.
<andrewrk> just add general comments to the PR
<andrewrk> syscalls as an enum is more complicated because the syscalls that are available are arch-dependent
<andrewrk> why private? I'm saying that it can be as you suggested, where they're not in std.os.posix
<andrewrk> try to be specific with your review - this change is necessary and happening. it solves a bunch of things that weren't solved before. but if there are specific improvements to be made I'm happy to do them
<daurnimator> andrewrk: comment left. (I also feel like this is something that might be easier discussed with voice/audio)
<daurnimator> comment updated with better formatting and an extra dot point or two
<merlyndmg> Was about to look into getting rid of the console when building on windows and found an unmerged pull request from two weeks ago. I'm guessing that's not done yet :)
<merlyndmg> getting more and more curious how these linux->windows cross compiles are working out perfectly. some magic there!
coolreader18 has quit [Ping timeout: 272 seconds]
<fengb> It's actually so seamless that I get confused when it's not available in other langauges
<merlyndmg> hmmm trying to figure out if there's a way to just send arbitrary linker commands from the build script
<merlyndmg> found some addBuildOption thing, but not sure quite how it works yet
fengb has quit [Ping timeout: 256 seconds]
<merlyndmg> hmm, looks like it might be a convention to add variables to some standard compile-time config file, not necessarily something that actually affects the build behavior itself
<emekankurumeh[m]> what do you mean get rid of console on windows?
<emekankurumeh[m]> if you want to disable the console for graphical applications just pass --subsytem windows to zig when building
<merlyndmg> I'm building the tetris example myself on windows, and seeing what I can do to document or improve that process. The version I am compiling right now is popping up the window, like it should, but is also popping up a console window as well. The "official" windows binary off the readme doesn't do that. I think it's cross-compiled from linux
<merlyndmg> "just pass this when building" so far I've been using the build.zig script. I haven't figured out a way to pass arbitrary flags to the build command, only specific ones that have been crafted in the build system to pass through. If there's a magic passthrough or a way to get my build command line that would help a lot :)
<merlyndmg> (the build command line that corresponds to what the build script is doing)
<merlyndmg> but yeah, I found the --subsystem windows flag, and I figured out a way that I *think* scammed the build system into giving up the command line. Trying it out now
Ichorio has joined #zig
<daurnimator> merlyndmg: "giving up"?
<daurnimator> merlyndmg: are you looking for --verbose-cc?
<emekankurumeh[m]> no, a way to pass raw args to the zig build process
<emekankurumeh[m]> through a build script
<merlyndmg> --verbose-cc only works for C targets. I have zig targets as well. Looking for the equivalent "zig.exe build-exe" command line
<merlyndmg> I added an error to one of my source files and it spit it out. Would be nice if I could find a command line option that did it on purpose
<merlyndmg> --verbose-link is helping me debug the subsystem thing a tiny bit, but it's definitely passing /SUBSYSTEM:console even though I specified --subsystem windows on the zig build-exe command line
<merlyndmg> starting to think I should be running zig.exe in a debugger :)
hio has joined #zig
Aransentin has quit []
<merlyndmg> hrm, not sure if this should be a bug report without running the compiler in a debugger. But it seems like the codegen tries to auto-detect the subsystem whenever any key named functions get exported, and wipes out whatever your subsystem selection is. But that doesn't work so hot, because it also seems that you can't actually provide any function name besides "main" or bootstrap.zig dies
<merlyndmg> so can't just switch to using WinMain for example
<merlyndmg> I will try to see if I can compile the compiler and make sure I'm actually hitting those breakpoint before I submit it though
<daurnimator> merlyndmg: hrm? you should be able to use WinMain
noonien has quit [Read error: Connection reset by peer]
<merlyndmg> If I just rename the entry point to WinMain, I get an error here while building:
<merlyndmg> C:\Users\fjkdlafjkdlaf\development\zig-windows-x86_64-0.4.0+b660134a\lib\zig\std\special\bootstrap.zig:107:33: error: root source file has no member called 'main'
<merlyndmg> there's a chance this behavior changed since 4.0. I accidentally clobbered my master build and replaced it with the 4.0 build. Let me reacquire the master build and see if that helps...
<merlyndmg> (hence why line 107 vs line 113)
<merlyndmg> nope, same error on line 113 now
noonien has joined #zig
<daurnimator> maybe line 14 needs to gain a WinMain case?
<daurnimator> uh, 17
<merlyndmg> I think WinMainCRTStartup is the shim that's normally added that calls winmain. However in this case it's calling `callMain` which is still trying to call standard main
<merlyndmg> line 51 (last line of WinMainCRTStartup) I think should be calling WinMain instead?
<merlyndmg> been a while since I've done win32 junk, so going off old memories
* daurnimator would need to look closer; but my guess is that the logic in https://devblogs.microsoft.com/oldnewthing/?p=10573 needs to be added to bootstrap.zig?
<merlyndmg> Yeah that article seems to match exactly what I saw when going through the source code over the last few minutes
<merlyndmg> the "security cookie", setting up for SEH, grabbing some handles, setting up QueryPerformanceCounter, etc
<merlyndmg> Since a lot of that is for C++, can probably do a simpler version of a lot of it
<merlyndmg> or a possibly better idea (maybe it breaks some compatibility use cases?) is to let the user manually specify the stuff and only auto-detect stuff as a fallback. I'd rather not have a WinMain in a cross-platform compatible program
<merlyndmg> If it's indeed clobbering my options, I'd rather it didn't do that :)
<merlyndmg> oh. "the source code" I meant above was the CRT source code that comes installed w/ visual studio, not the zig source code
lqd has quit [Ping timeout: 248 seconds]
knebulae has quit [Remote host closed the connection]
lqd has joined #zig
nikki93 has quit [Ping timeout: 252 seconds]
noonien has quit [Ping timeout: 250 seconds]
nikki93 has joined #zig
<merlyndmg> "both C and C++ will initialze the so-called security cookie
<merlyndmg> used as part of
<merlyndmg> stack buffer overrun detection." - sounds like this might be an important thing to do on windows
r1b has quit [Ping timeout: 248 seconds]
<merlyndmg> (also from that raymond chen article you linked)
noonien has joined #zig
cbarrett has quit [Ping timeout: 250 seconds]
r1b has joined #zig
<merlyndmg> A fairly related article on people trying to hack around this and the caveats. They're using C++ though: https://handmade.network/wiki/2824-tutorial_how_to_avoid_c_c++_runtime_on_windows
<merlyndmg> Seems that putting large values on the stack blows up, seemingly related to that "security cookie" thing. Not sure if zig has to worry about that or not, if linking to pre-compiled code for example.
cbarrett has joined #zig
<merlyndmg> anyhow, this is all a tangent for me. I just care about the subsystem right now :) and I should worry about that tomorrow instead, cause it's late
<merlyndmg> oh, also could be that global C++ constructors won't get called unless the right startup code is invoked, too. If that C++ code is extern "C", could be linked by zig, too.
hio has quit [Ping timeout: 248 seconds]
hio has joined #zig
sadanjon has joined #zig
rbscott has joined #zig
sadanjon has quit [Client Quit]
<rbscott> Hello, I recently submitted a PR(https://github.com/ziglang/zig/pull/2469) to implement unionInit, but wasn't sure what is required to contribute. Any chance someone can point me in the right direction?
<daurnimator> rbscott: sending a PR is all you have to do.
<daurnimator> rbscott: misc things I notice: 1. trailing whitespace in your files. 2. WIP commits. -> I'd rebase those away.
<rbscott> Sounds good, I will sort out those items. Is there a recommended linter by any chance?
<daurnimator> rbscott: run through `zig fmt` :)
<daurnimator> rbscott: for the C++ code I'm not so sure
<rbscott> daurnimator: Wil do, thanks!
avoidr has quit [Quit: leaving]
rbscott has quit [Ping timeout: 256 seconds]
Ichorio has quit [Ping timeout: 248 seconds]
return0e has joined #zig
<tgschultz> unionInit would clean up a hack I had to do in Deserializer. I'll have to keep an eye out for the merge so I change that right away.
rivten has joined #zig
knebulae has joined #zig
hio has quit [Quit: Connection closed for inactivity]
meheleventyone has joined #zig
meheleventyone has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
meheleventyone has joined #zig
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
meheleventyone has quit [Quit: Textual IRC Client: www.textualapp.com]
FireFox317 has joined #zig
<emekankurumeh[m]> daurnimator: that would depend on https://github.com/ziglang/zig/pull/2462
halosghost has joined #zig
nilshi has joined #zig
FireFox317 has quit [Read error: Connection reset by peer]
SamTebbs33 has joined #zig
rivten has quit [Quit: Page closed]
marijnfs_ has quit [Read error: Connection reset by peer]
hio has joined #zig
avoidr has joined #zig
<nilshi> Hello. I'm starting with the zig tutorial right now.
<nilshi> Is anyone using the editor Geany and has recommendation for a color scheme etcß
<nilshi> ?
<andrewrk> hi nilshi
<andrewrk> I believe the 2 popular editors for zig are vscode and vim
<tgschultz> someone was on here a few days ago with a Geany build with zig support weren't they?
<nilshi> I put zig run %file as build and I'm using C color scheme at the moment. This is quite fine for most of the way. I was just wondering if anyone is active in that direction
<nilshi> as tgschultz says, it seems so
<nilshi> very good, exactly what I need
<nilshi> thanks
<merlyndmg> can remove the filter to see the whole conversation (if "geany" isn't in the particular message)
<merlyndmg> link to chat log tool is in the channel topic, for future reference
<nilshi> colors are good and it show me the line with errors. cool
<tgschultz> colors are fabulous: http://zig.tgschultz.com/unicorn_vomit.png
<nilshi> I am waiting for a language that uses colors as syntax. You set the color and that defines the type or meaning :)
<nilshi> sorry, I am not sure how the offtopic/joke rules are in this channel.
<andrewrk> nilshi, as long as it's friendly & positive tangential topics are ok
<andrewrk> the more controversial something is, the more it must be strictly on topic
<nilshi> affirmative
<tgschultz> nilshi: see colorForth
Ichorio has joined #zig
sadanjon has joined #zig
<sadanjon> Hi!
<andrewrk> hi sadanjon
<sadanjon> Hi andrew, I'm new to zig, I was following the documentation trying stuff out,
<sadanjon> and I got to the defer/errdefer stuff, and I was trying to return an error from a tagged scoped ('blk: {}')
<sadanjon> I never used IRC before, can I paste code here?
<sadanjon> anyway, I didn't get what I was expecting, it looked like it didn't execute the errdefer blocks/expressions
<sadanjon> pastebin link to the function I was calling: https://pastebin.com/ATjRBZUX
<sadanjon> I was expecting it to print: "xxx 1\nxxx 3\nxxx 2\n" if called with true, but it print "xxx 1\nxxx2"
<sadanjon> help? :)
<tgschultz> yeah, on godbolt it confirms that the errdefer isn't even compiled.
<tgschultz> I don't see an existing issue for it, but it seems like a bug to me.
<tgschultz> oh interesting... sadanjon, what happens when you call with false?
<sadanjon> ah same result I think, let me recheck
<sadanjon> yes
<sadanjon> *same result
<tgschultz> ok, yeah, that matches godbolt. for a second there I thought it had compiled the errdefer
scientes has joined #zig
<sadanjon> Hi, tgschultz, I tried another variation here: https://pastebin.com/9cSWxx85 this one gives out an error 'error: unable to make error union out of number literal'
<tgschultz> I'm pretty sure that is a known issue, you'll have to cast it `i32(1);`
<sadanjon> Ah I see, cool, thanks!
<sadanjon> Should I try to open an issue on github?
<andrewrk> I'm pretty sure there's an issue for that already
<sadanjon> Thanks tgschultz, andrewrk <3
halosghost has quit [Quit: WeeChat 2.4]
scientes has quit [Ping timeout: 272 seconds]
<nilshi> Any recommendation to get a 2D drawing frame on the screen and an event loop for keypresses?
<andrewrk> nilshi, SDL2 or GLFW
<nilshi> via C, right?
<andrewrk> yes
Ichorio has quit [Ping timeout: 250 seconds]
<emekankurumeh[m]> nilshi, several people are working on pure zig solutions to that me, included
<nilshi> that is good to know
<nilshi> I don't know any of the game oriented toolkits anyway, so I have to learn everything.
<nilshi> SDL, Raylib or whatever the names for the C libs
marijnfs has joined #zig
<nrdmn> what's the current state of package management in zig? Is anything about that being worked on?
<andrewrk> nrdmn, look at the roadmap sections of 0.3.0 and 0.4.0 release notes
<nrdmn> hmm ok
marijnfs_ has joined #zig
<BitPuffin> nilshi: yeah I've started using raylib in zig
<BitPuffin> It wouldn't be a bad idea to write a competitor in pure zig
marijnfs has quit [Ping timeout: 268 seconds]
<nilshi> BitPuffin: raylib has been on my list for quite a while. But first I have to look up how to properly call C code from zig.
Ichorio has joined #zig
marijnfs_ has quit [Ping timeout: 246 seconds]
marijnfs has joined #zig
marijnfs__ has joined #zig
marijnfs has quit [Ping timeout: 248 seconds]
coolreader18 has joined #zig
<andrewrk> my posix api layer branch is up to 64 files changed, 8744 insertions(+), 10578 deletions(-)
<emekankurumeh[m]> and https://github.com/emekoi/ziglet
<emekankurumeh[m]> i don't know what happened but a ton of stuff just broke on windows
<emekankurumeh[m]> i'm getting a ton of errors like `error: import of file outside package path: 'windows/advapi32.zig'`
<andrewrk> emekankurumeh[m], if you're using zig test or zig run it has to do with your cwd
<emekankurumeh[m]> i'm using zig build-exe in the examples directory
Ichorio has quit [Read error: Connection reset by peer]
<andrewrk> it worked for me
<emekankurumeh[m]> it's only when i try to build hello_windows.zig
hio has quit [Quit: Connection closed for inactivity]
<emekankurumeh[m]> here's the full output: https://gist.github.com/emekoi/a9e74028e13553e022e7f7348f364635
<emekankurumeh[m]> though this could be me (i'm not on master) but i don't think my changes would have any effect on this
marijnfs__ has quit [Ping timeout: 252 seconds]
marijnfs__ has joined #zig
marijnfs_ has joined #zig
<marijnfs_> is there a writeup on the package manager somehwere?
<andrewrk> marijnfs_, no
<emekankurumeh[m]> i think i found the error
<emekankurumeh[m]> `use` is broken
<emekankurumeh[m]> when you `use` a file that `use`s another file zig can't find the second file
<andrewrk> emekankurumeh[m], can you try applying https://github.com/ziglang/zig/pull/2532?
<marijnfs_> is the package manager gonna be in a live coding soon?
<andrewrk> marijnfs_, getting an early version of the package manager done is a 0.5.0 goal, and if accomplished going to be a major feat
marijnfs__ has quit [Remote host closed the connection]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 272 seconds]
<marijnfs> sweet
<marijnfs> is there a reason why zig doesn't configure with llvm-9? I can't build it now
<andrewrk> I haven't made an llvm9 branch yet
<andrewrk> llvm trunk is still in breaking changes mode; they haven't branched for 9.0.0 yet
<marijnfs> yeah the llvm structure changed a lot
<daurnimator> andrewrk: is there a provisional date for 0.5.0?
<daurnimator> andrewrk: as much as I would like the package manager in there.... I have a high suspicion that it will take on the order of a year to get one written
<andrewrk> the due by date is a reasonably accurate estimate
<daurnimator> I'd be happy if the next release just contained fixed coroutines + all the reorg we're doing now
<andrewrk> daurnimator, will you have a look at the posix api layer thing with my latest pushed commits?
<andrewrk> I think you will like it much better
<daurnimator> andrewrk: I saw the 'bits' commit
<andrewrk> yeah that's what I'm referring to
<andrewrk> I'm pretty sure this is exactly what you want sans the SYS_ enum thing
<andrewrk> I'm happy with it too
<daurnimator> I don't particularly understand the 'bits' layer of indirection
<andrewrk> now I'm just following the red brick road
<emekankurumeh[m]> no disrespect, but i agree with daurnimator on this one
<emekankurumeh[m]> copy elision too of course
<andrewrk> it's inspired from musl
<daurnimator> andrewrk: I'd be happy with just std/os/${buildin.os}.zig
<daurnimator> because... that's really what 'os' should be to me
<andrewrk> the bits thing is needed to make everything work
<daurnimator> andrewrk: what will there be in std/os that's *not* 'bits'?
<andrewrk> emekankurumeh[m], yeah we're all on the same page. those are the first things to do
<andrewrk> have a look at the comment at the top of std/os.zig as of the latest commit in that branch
<daurnimator> andrewrk: see my comment for why I don't think that should exist...
<andrewrk> yep
<daurnimator> andrewrk: "Convert "errno"-style error codes into Zig errors." => std/os wouldn't have errno in the first place; 'errno' would be a std/c* concept
<daurnimator> "cross platform abstracting." => I don't think this belongs in std/os
<andrewrk> I don't think you're trying to solve the same problem I am
<daurnimator> andrewrk: could you re-read through https://github.com/ziglang/zig/pull/2527#issuecomment-495469872 and let me know which parts you agreed with/don't?
<andrewrk> daurnimator, if errno is a c concept, where does the code go that turns libc errno into zig errors? is it duplicated N times for darwin, freebsd, netbsd, dragonflybsd, and what about linux when linking libc?