<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>
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
<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>
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
<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
<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
<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
<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
<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]