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/
Flaminator has quit [Ping timeout: 252 seconds]
Flaminator has joined #zig
<andrewrk> vramana, yes it's a problem. I've been putting off doc generation, hoping to only do it in self hosted
Guest68277 has quit [Read error: Connection reset by peer]
Guest29080 has joined #zig
Guest29080 has quit [Client Quit]
wilsonk|2 has joined #zig
<dirkson> andrewrk: Say, mind if I ask what distro you tend to code on?
<andrewrk> dirkson, NixOS
<andrewrk> it helps isolate environments so you don't have accidental system dependencies
<dirkson> andrewrk: Interesting! I stumbled across your name in #alpine-linux and got curious. You're easy to notice because "Party Hard" plays in my head whenever I see your name.
diltsman has joined #zig
<daurnimator> dirkson: why party hard music?
<daurnimator> dirkson: last night a friend put on the "party boy" music.... all I could think was that it wasn't that different to "party hard"'s music
<dirkson> daurnimator: It's sung by "Andrew WK"
<daurnimator> dirkson: oh. that party hard. I was thinking of https://www.youtube.com/watch?v=KzXOde57jQY
<dirkson> I was not familiar with this, but I am now and I love it.
<daurnimator> pretty fun game. good local coop too
<diltsman> Why do I remember Compiler-RT being included in the source download for Clang or LLVM?
Flaminator has quit [Ping timeout: 246 seconds]
<wilsonk|2> diltsman: I don't remember compiler-rt ever being included. I always have to remember to download separately and unpack it in the tools dir (along with clang)...then build llvm :)
<diltsman> Huh. Anybody know the repository for compiler-rt?
<diltsman> Nevermind. I found the Github mirror.
_whitelogger has joined #zig
darithorn has quit [Remote host closed the connection]
<andrewrk> wilsonk|2, if you're getting that error you probably didn't build the INSTALL target
<wilsonk|2> andrewrk: basically cut and pasted from the build instructions? (just changed the install dir)
<wilsonk|2> So I used the 'INSTALL.vcxproj' arg to msbuild in other words
<vramana> Currently I am a bit stuck on how to do heap allocation. Hopefully docs around the can be improved soon.
<wilsonk|2> Ah, strange...I thought the 'zig.exe' in the Release directory was the zig to use from the command line but apparently the '[path-to-zig-install]/Userswilsonkzigbuild/bin/zig.exe' is the one to use...that way there is no 'unable to find zig lib directory' error
<wilsonk|2> back in a minute
wilsonk|2 has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
<andrewrk> vramana, https://github.com/ziglang/zig/issues/1904 - should be done within a month
<vramana> andrewrk: Thanks
<vramana> https://imgur.com/a/I0RwpcO Is this the expected error for this case? Can the error be better saying function return type is forgotten?
<vramana> andrewrk: ^
<vramana> Also thank you for making a vim plugin that works really nicely.
dewf has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 272 seconds]
<mikdusan> vramana: i suspect compiler error messages will get usability improvements in the self-hosted compiler
<vramana> When I run zig binary am I using stage-1 compiler ?
<emekankurumeh[m]> there is an existing issue for that but things like nicer error messages will be primarily in the self-hosted compiler
<emekankurumeh[m]> vramana: you are most likely using stage 1 as the self-hosted compiler is incomplete
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 246 seconds]
<vramana> mikdusan: emekankurumeh[m] Thanks
marmotini_ has joined #zig
Ichorio has joined #zig
Ichorio has quit [Ping timeout: 252 seconds]
Flaminator has joined #zig
wilsonk has joined #zig
DutchGh0st has joined #zig
marmotini_ has quit [Remote host closed the connection]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Hejsil has joined #zig
<mikdusan> is there an @import “using” that folds names into importing space?
<vramana> Just don't assign the @import to const. That should do what you are asking for is what I heard in a video iirc.
<Hejsil> mikdusan, use @import("something.zig")
<Hejsil> I don't recommend using 'use' though
<mikdusan> i have a corner-case — benchmarking different code snippets. so i want the bench block to share some “base” without qualifying it. eg. making an iterator for binary data, and want to changeout just the “next()” function with various Zig and C implementations. so i’m parting those out into their own .zig files.
<Hejsil> I think I could come up with a way to do it without use, but I don't think it's a bad use case. Do you have the code somewhere?
<mikdusan> i’ll put it on github in a day or so. want to get a few benches tied in.
<Hejsil> Well, as long as the use case is better than "writing out the namespace names is a pain" then I think 'use' is fine
Hejsil has quit [Quit: Page closed]
halosghost has joined #zig
darithorn has joined #zig
Akuli has joined #zig
<Akuli> how do i convert []const u8 to [*c]const u8? i want to call a @cImport function
<Akuli> i tried creating a 0-terminated []u8 and copying the []const u8 there, but i get a type error when i try to call the c function
<Akuli> error: expected type '[*c]const u8', found '[]u8'
<Akuli> ummmmm nevermind... i just need to use .ptr
<Akuli> how do i catch a specific error?
<Akuli> something like: doSomething() catch(error.WhatEver) { ... }
<Akuli> nevermind, turns out that an enum is better for this use case
<Akuli> nevermind, turns out that an enum is better for this use case
<Akuli> oops
Ichorio has joined #zig
klltkr has quit [Ping timeout: 258 seconds]
<andrewrk> Akuli, I recommend the pattern foo() catch |e| switch (e) { // enumerate all the errors
<andrewrk> you can start with enumerating none of them and the compiler error will tell you all the errors you need to handle
<andrewrk> this has the benefit that when you remove a possible error or add a new one, you'll get a compile error here telling you to update your code
Hejsil has joined #zig
<andrewrk> it just occurred to me that we could make the pub fn panic thing a userland concept
<Akuli> i remember looking at the @panic builtin and feeling like why is this not implemented in pure zig :D but that would still need some powerful way to abort i guess? libc has abort()
<andrewrk> @panic isn't going away
<andrewrk> just the internal compiler magic of detecting pub fn panic
wilsonk has quit [Ping timeout: 244 seconds]
bheads has quit [Remote host closed the connection]
wilsonk has joined #zig
wilsonk has quit [Ping timeout: 245 seconds]
<Akuli> should the compiler find integer macros defined in .h files?
<Akuli> it's not finding all of them to me
<andrewrk> some are impossible to translate; for others zig's C parsing isn't sophisticated enough yet
<Akuli> i think this is the latter kind
<Akuli> should i make an issue?
bheads has joined #zig
wootehfoot has joined #zig
<Akuli> i commented there
vegecode has joined #zig
<vegecode> Quick question, do I need to build llvm from source now in order to build master branch? My ubuntu repository version use to work fine but now I get build errors.
<Akuli> vegecode, no, but you need to download llvm from their ppa
<Akuli> zig on master works with llvm 7 http://apt.llvm.org/
<andrewrk> vegecode, what build errors do you get?
<Hejsil> andrewrk, how is the ResultUsed system ment to work in translate-c? Should ResultUsed be passed to trans_integer_literal or should the caller of trans_integer_literal wrap with _ = 1?
<andrewrk> Hejsil, let me read some code to refresh my memory
<andrewrk> Hejsil, I think it's currently assumed to be ResultUsedYes for integer literals
<andrewrk> sorry I don't fully understand your question and my memory is fuzzy
<Hejsil> Well, the trans_integer_literal was just an example. I'm asking a little more generally
<Hejsil> '1;' is a valid statement, but it currently translated incorrectly
<andrewrk> I see, so the question is, where in the code is it supposed to insert the `_ = `
<Hejsil> Yes
<andrewrk> maybe_suppress_result is a clue
<Hejsil> Hmm, it's probably best to call maybe_suppress_result in all trans_stmt_extra cases where relevant
<Hejsil> So not for 'return
<Hejsil> but for '1'
<Hejsil> And then not pass ResultUsed further down
<andrewrk> at this point I think your understanding is more fresh than mine, I'd be doing the same process as you to figure it out
<Hejsil> Alright, I
<Hejsil> 'll mess around with it a little
<andrewrk> btw I'm hoping to migrate translate.cpp over to userland during the 0.5.0 release cycle
<Hejsil> Wont we need translate-c because of clang headers?
<Hejsil> Or custom headers even
<andrewrk> what do you mean?
<Hejsil> Hmm
<Hejsil> Im guessing we will have a zig_clang.cpp, and then a zig_clang.zig which is a "zig header" for zig_clang.cpp
<Hejsil> is that the plan?
<andrewrk> the only downside as far as I can see is having to maintain zig_clang.h as well as a .zig equivalent of the .h file
<andrewrk> ah you just said that :)
<Hejsil> Alright that makes sense :)
<andrewrk> what's kinda cool about this idea though - is that we'll link stage 1 2x
<andrewrk> the first time it won't have @cImport / translate-c support. then we build a userland library, and re-link, and now it has translate-c powers
<andrewrk> point being that we can have translate-c in userland even before we have the stage2 compiler done. because that will take a long time
<andrewrk> and then we can be investing in the real, userland implementation of translate-c
<Hejsil> Why link twice? wouldn't translate-c work like stage 1 fmt
<andrewrk> that's one possible way to implement it, with a child process. another way is with a function call to a static library
<andrewrk> as far as I see it, function calls are cheaper (especially on Windows) and less can go wrong
<Hejsil> Right
<andrewrk> so even stage1 will be a "hybrid" of self-hosted and C++ code
<Hejsil> stage 1.5 :)
<andrewrk> :)
<andrewrk> once stage2 is done, if we don't rely on @cImport, we could remove stage 1.5, and just go straight from 1 to 2
<andrewrk> not much of a difference, really
<Hejsil> Because we are gonna maintain "zig" headers for things like "zig_llvm" and "zig_clang"
<Hejsil> ?
<andrewrk> right - the clang one is necessary either way if we want userland translate-c. and already it's kinda nice to have zig pointers rather than C pointers for the llvm API
<Hejsil> Alrighty, then I wont work to much on perfecting this PR. I'll just what I need to work
<andrewrk> sounds reasonable
<andrewrk> we start taking pride in the translate-c code when we get to userland
<andrewrk> it's a non trivial chunk of work to create zig_clang.h
<andrewrk> the list of tasks required to keep up with third party projects is growing - but it's worth it
<andrewrk> that's one of the things that zig is abstracting for its users
<vegecode> sorry I have to go
vegecode has quit [Quit: Page closed]
wink_ has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<Akuli> Hejsil, how do i use zig-clap in my zig project? with a git submodule?
<Hejsil> Akuli, that's probably the best option right now
<Hejsil> Wasn't there someone who used reflection to load opengl functions or something like that?
<Akuli> umm... how do i import it then? i guess @import("../zig-clap/src/whatever") is not particularly good style?
<andrewrk> Akuli, you're using build.zig right?
<Akuli> yes
<Hejsil> Hmm, link is longer than the line I wanted to show, lol
<Akuli> neat!
<andrewrk> zig package manager isn't here yet, but you can sort of fudge it in the meantime :)
<Akuli> so then i just @import("zig-clap")?
<andrewrk> yep
<Akuli> awesome
<Hejsil> zig-clap is used an old style of namespacing. I haven't really updated my repos to the new style yet.
<Hejsil> I'm kinda blocked on the @typeOf(@bytesToSlice()) issue
<andrewrk> ah I didn't know that
<andrewrk> I can prioritize that one
<andrewrk> do you have a link handy?
<andrewrk> thanks
<andrewrk> ah this one
<Hejsil> andrewrk, I tend to post an issue and the try to work around, or fix it before claiming that an issue is blocking me :)
<andrewrk> Hejsil, as a workaround can you make the type explicitly with `[]T` syntax?
<Hejsil> Hmmm, actually I might be able to do it that simple. I have some tests that ensure that all pointer properties are transfered as expected but in my code I only ever need the const property
<andrewrk> ah I see, it's a matter of the pointer properties
halosghost has quit [Quit: WeeChat 2.4]
Hejsil has quit [Quit: Page closed]
<Akuli> how to get the biggest value of an unsigned integer type? there are some mentions of maxValue(T) in comments of stdlib
<andrewrk> std.math.maxInt(T)
<Akuli> thanks again :D sorry for not finding these things myself
<mikdusan> i inverted some syntax and the compiler crashes: https://gist.github.com/mikdusan/457a2797fcfa35ae320d692a2b7d4a69
Akuli has quit [Quit: Leaving]
Zaab1t has joined #zig
dewf has quit [Quit: Leaving]
wilsonk has joined #zig
darithorn_ has joined #zig
darithorn has quit [Ping timeout: 250 seconds]
<andrewrk> I just pushed a breaking change to std.mem.Allocator interface API
Sahnvour has joined #zig
<Sahnvour> hi
<Sahnvour> andrewrk: about the c_abi test failing on windows, is it expected that the C module (cfuncs.obj) have debug symbols ?
<andrewrk> Sahnvour, yes, because we add `-g` to the options
<andrewrk> I wonder, is some other step needed to make clang output pdb debug symbols on Windows?
<Sahnvour> I don't know yet; the build.zig does not specify -g, however adding it myself does not seem to work either
<Sahnvour> ok, right
<andrewrk> here we try to make C source code match zig args. I think we probably need to figure out how to enable PDB debugging with clang, now that I think of it I think it is behind some flag
<Sahnvour> I'm used to clang-cl.exe on windows, which accepts the same args as regular cl.exe
<Sahnvour> but I don't know if it is simply remapping them to classic GCC-style arguments
<andrewrk> that should match `zig cc` exactly
<Sahnvour> if it's not, maybe additional behaviour is wanted for windows
<andrewrk> I think -Z7 ?
<Sahnvour> yes
<andrewrk> so codegen.cpp in that line I linked, should check if the target is windows, and add -Z7 too
<andrewrk> idk what -MTd does, I couldn't find docs for that. looking at http://blog.llvm.org/2017/08/llvm-on-windows-now-supports-pdb-debug.html
<Sahnvour> it says to link against multithreaded libc in debug version iirc
<andrewrk> ahh
<andrewrk> I think that is irrelevant. I expect the -Z7 arg to fix debug info
<Sahnvour> the debug part I'm sure about
<andrewrk> I'll be back in a bit
Zaab1t has quit [Quit: bye bye friends]
<Sahnvour> given that internal clang is fed with gcc arguments, I don't know how to make it accept a cl.exe one
<Sahnvour> the other way around is easy, giving gcc arguments to cl.exe
<Sahnvour> -Z7 gives `zig.exe: error: unsupported use of internal gcc -Z option '-Z7'`
<Sahnvour> and /Z7 in cl.exe style `zig.exe: error: no such file or directory: '/Z7'`
<Sahnvour> we'd have to use the cl.exe driver somehow
<Sahnvour> trying -mllvm /Z7 `clang (LLVM option parsing): Unknown command line argument '/Z7'. Try: 'clang (LLVM option parsing) -help'`
<Sahnvour> ha, found it, --driver-mode=cl
keegans has joined #zig
<keegans> " type '[*]const u8' does not support array initialization" with `const command = [*]const u8{c"sh", c"-c", c"echo hello"};`, for example -- what should I be doing instead (just started writing zig)
Sahnvour_ has joined #zig
<keegans> got it using ` var command: [4][*]const u8 = undefined;` -- but that's annoying
<keegans> or 3, rather
Sahnvour has quit [Ping timeout: 244 seconds]
<andrewrk> keegans, there are 2 planned issues that will make this better, but here's the answer: const command = [][*]const u8{c"sh", c"-c", c"echo hello"};
<andrewrk> Sahnvour_, does --driver-mode=cl interfere with anything else?
fsateler_ has joined #zig
<Sahnvour_> yes, i'm trying to prefix all arguments with -Xclang except /Z7 but I'm having trouble making it work
fsateler has quit [Read error: Connection reset by peer]
<andrewrk> keegans, this will remove the necessity of prefixing with `c`: https://github.com/ziglang/zig/issues/265
<keegans> ah, very nice
<andrewrk> this will make the syntax [_][*]const u8 instead of [][*]const u8: https://github.com/ziglang/zig/issues/1797
<keegans> makes more sense
<andrewrk> so after these issues it would be: const command = [_][*]null const u8{"sh", "-c", "echo hello"};
<keegans> :D
<keegans> ah this is very strange ??
<keegans> given `const command = [][*]const u8{c"-c", c"echo hello"};` and `const status = execve(c"/bin/sh", &command, @intToPtr([*]const ?[*]const u8, 0));`
<keegans> some data is leaking into the system call
<keegans> they are all null terminated, yet strace is showing something else is getting passed causing -1 EFAULT (Bad address)
<keegans> ` execve("/bin/sh", ["-c", "echo hello", " -D{}=[{}]Expected argument aft"..., " `
<andrewrk> your command itself does not have a null entry. this would also be solved by #265
jjido has joined #zig
<andrewrk> const command = []?[*]const u8{c"sh", c"-c", c"echo hello", null};
<andrewrk> I'm going afk, bye
<keegans> ah thank you for your help
<keegans> i cant believe i forgot to terminate the end of the array, yeah
<keegans> the proposal will certainly help me not make these dumb mistakes lol
Sahnvour_ has quit [Quit: Leaving]
<keegans> how can i concat strings , i.e.: like `const target_file_path = current_work_dir ++ "/src/main.zig";`
<keegans> yet current_work_dir is not known at compile time
<keegans> and is MAX_PATH_BYTES in size
Ichorio has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<keegans> got it with mem.copy, but is there a proposal for a shorthand for `x[0..x.len]`
<andrewrk> keegans, not sure what you mean - x[0..x.len] is just x
<keegans> oops
<andrewrk> unless x is an array, in which case you want &x
<keegans> i am having trouble understanding when something is a copy
<keegans> if i have an array in a function and i return it, it is copied, yes ?
<keegans> because it is allocated on the stack likely
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
<keegans> nope
<andrewrk> the result location for the return value is determined at the callsite
<andrewrk> right now there's an intermediate copy but that's soon to change
<keegans> ok , good to know ,thank you