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/
<andrewrk> marijnfs, what gives you this idea?
<marijnfs> andrewrk: I'm getting build.zig:11:5: error: expected token '}', found 'DocComment'
<marijnfs> when I use a /// for commment
Ichorio has quit [Ping timeout: 245 seconds]
keithdc has joined #zig
<pixelherodev> i recall seeing similar
<pixelherodev> pretty sure it's a bug in the error message
lunamn_ has joined #zig
ky0ko has quit [Read error: error:1408F10B:SSL routines:ssl3_get_record:wrong version number]
<fengb> /// is a doc comment which can only go right before a declaration. // is a regular comment
lunamn has quit [Ping timeout: 240 seconds]
keithdc has quit [Remote host closed the connection]
<pixelherodev> Ah - maybe it's time to edit " eventually, it will become a compile error to have a doc comment in an unexpected place, such as in the middle of an expression, or just before a non-doc comment." in the docs :)
crimson_penguin has quit [Ping timeout: 264 seconds]
crimson_penguin has joined #zig
utzig has quit [Ping timeout: 276 seconds]
lunamn_ has quit [Ping timeout: 265 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
wootehfoot has quit [Read error: Connection reset by peer]
muffindrake has quit [Ping timeout: 246 seconds]
muffindrake has joined #zig
mla has joined #zig
reductum has joined #zig
chemist69 has quit [Ping timeout: 245 seconds]
chemist69 has joined #zig
_whitelogger has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
_whitelogger has joined #zig
mahmudov has quit [Ping timeout: 240 seconds]
doublex has quit [Remote host closed the connection]
doublex has joined #zig
<mq32> nrdmn, thanks for the comments, gonna fix it now :)
<mq32> fengb, a question on wasm: can i load wasm from a local html file or does this require a server?
<reductum> mq32: for a while firefox would let you load it directly from local file, but now you need a server
<reductum> I think chrome has required a server for a long time. I don't know about other browsers.
mahmudov has joined #zig
<mq32> sad :(
<andrewrk> this is a problematic restriction
<reductum> Yes it's unfortunate.
<reductum> What I do now is just `python3 -m http.server` in the dir with the wasm module.
<bgiannan> andrewrk, any idea what that might be: https://0x0.st/z3-R.txt ? I could not managed what triggers it in my code yet.
<reductum> If the zig stdlib included a similarly super basic http server, maybe that could be used.
<andrewrk> bgiannan, you will actually get a better error if you don't do --verbose-ir. in your paste, the code doing verbose-ir itself crashed before the actual problem happened
<mq32> reductum, would still require you to startup an http server to read the docs
<mq32> which is just "not simple" ;)
<bgiannan> andrewrk, i had not input at all without it
<bgiannan> output rather
<reductum> Oh I just got here. Were you talking about docs? I was talking about testing local wasm files in the browser.
<bgiannan> i'll try and build zig myself so i can get a error stacktrace
<andrewrk> bgiannan, that will help
<mq32> reductum, yeah my big question was if i could run wasm in the docs
<mq32> but i think that andrew would have already done this if it would be possible
<andrewrk> mq32, unfortunately, being able to see it with file:/// is an important feature
<mq32> yeah i'm totally with you there. not requiring a server is just too important
<reductum> Oh hey there's a setting you can change in Firefox for this: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp
<reductum> privacy.file_unique_origin. If you set it to false, you can run wasm files without a server.
<reductum> I'm doing it right now.
<mq32> reductum, yeah but that doesn't help either, because anyone who wants to read the docs offline would have to do this
<andrewrk> I think firefox handled the CVE incorrectly
<andrewrk> it's assumed that files on a server are there on purpose, for access by the web page
<andrewrk> when looking at a file:/// URL, the browser assumes that the files are there intentionally as well, for css, images, and scripts
<daurnimator> mq32: oh hey look more motivation to work on the zig http server :)
* daurnimator really has too many tasks to get to
<andrewrk> but when a script tries to access same such resources, now firefox changes its mind, and says the files are not there on purpose, accessing them is a security vulnerability
<daurnimator> andrewrk: yes IIRC each file:// url is considered its own "origin"
<daurnimator> so you have the same restrictions as if you try and go cross-domain
<daurnimator> ==> <img>, <style> and a few other tags have always worked cross-domain; so they work across file://
<andrewrk> it's inconsistent and problematic. there should be a way to run web assembly without depending on this origin thing, just like it works for scripts, images, css
<daurnimator> but XHRs, wasm, and most neer stuff... is blocked cross-domain as well. and hence blocked for file://
<reductum> Chrome does the same.
<daurnimator> andrewrk: browser developers consider allow cross-domain scripts, images and css to be a mistake; but they have to keep it around for compat.
<andrewrk> it's a nice find that you can change it, but that doesn't really matter. the default is important
<reductum> Yup agreed. I was more selfishly excited about that discovery for my own project :P
<andrewrk> daurnimator, I don't think that's a valid excuse
<andrewrk> wasm must be able to be executed in the same context as <script> if it is to succeed
<daurnimator> andrewrk: true. but thats what they seem to think and I don't think I have a hope of changing their mind
<marijnfs> What do you guys get when you add: var testval = [*c]u8 {0};
<andrewrk> I don't either. but they're doing it wrong
<bgiannan> huh trying to install llvm 9 from https://apt.llvm.org/ but apt complains about missing public keys
<andrewrk> marijnfs, the expected outcome is a compile error. also, don't use c pointers
<andrewrk> bgiannan, scroll down and look for "archive signature"
<marijnfs> andrewrk: allright, I needed to pass a string to c. I guess I should use c"somethign".
<andrewrk> there you go
<bgiannan> i added `deb [trusted=yes]` and now it works
<andrewrk> good night. I'll be happy to help you with the compiler crash tomorrow bgiannan
<daurnimator> andrewrk: oh wow you haven't gone to sleep yet
<bgiannan> andrewrk, good night
<daurnimator> oh wait. I forgot I'm in a different timezone to normal
reductum has quit [Quit: WeeChat 2.6]
<mq32> daurnimator, what timezone are you in?
<daurnimator> mq32: currently germany
<mq32> ah, so we have the same local time :D
<marijnfs> Guten Tag
<marijnfs> I'm importing a c header, but when I call a function with it, I get a segfault, 'c' seeming to be 0
<daurnimator> marijnfs: what is 'c'?
<daurnimator> (you're going to need to post code)
<marijnfs> sure, whats the pastebin of choice here?
<marijnfs> like that basically
<daurnimator> marijnfs: and how are you trying to run/compile it? (please paste command line and output)
riba has joined #zig
<marijnfs> then I zig build, and run ./zig-cache/bin/pub
<daurnimator> marijnfs: (aside): you shouldn't need addLibPath
<marijnfs> daurnimator: without it /use/lib64 doesnt seem to be a standard search path
<marijnfs> but anyway that can't be the error right?
<riba> i think i'm almost there, just having linker troubles now - it can't find system libraries
<riba> (output of pkg-config --libs)
<riba> does anyone have a pointer?
<riba> instead of zig build i'm using a monstrous command
<riba> and the one lib i specified with -L can be found too
<riba> in case it matters, i'm trying to make an .so with build-lib -dynamic -fPIC
<daurnimator> riba: can you share your build.zig and/or invocation?
<mq32> is there an easy way to allow "zig build run" to pass arbitrary parameters to my executable?
<riba> daurnimator: zig build-lib -isystem /usr/include/libpurple -isystem /usr/include/glib-2.0 -isystem /usr
<riba> /lib64/glib-2.0/include -isystem ./headers/jabber/ -isystem /usr/include/libxml2 -dynamic -fPIC -DPURPLE_PLUGINS -lc -L
<riba> /usr/lib64/purple-2 -lpurple -lglib-2.0 -lxml2 -lz -llzma -lm -ldl -lxmpp xoob.zig --disable-gen-h
<riba> sorry, it's longer than i thought
FireFox317 has joined #zig
<FireFox317> marijnfs: You forgot a linkSystemLibrary("c") in your build script
<FireFox317> You always have to add it when working with c libraries
<riba> maybe i'm having the same problem as marijnfs who had to add the system path
<daurnimator> riba: you probably need -L/usr/lib as well.
<marijnfs> FireFox317: thanks
<marijnfs> error: undefined symbol: __gxx_personality_v0
<riba> daurnimator: yeah just tried that and it works, but why is the system lib path not searched by default?
<marijnfs> hmm, maybe I can choose a different libc?
<daurnimator> marijnfs: heh... I tried to build your example..... and my computer ran out of memory and locked up. that was weird.
<mq32> marijnfs, what target are you using? x86_64-linux-gnu?
<marijnfs> hmm, maybe I can choose a different libc?
<marijnfs> sorry
<marijnfs> mq32: Yeah
<daurnimator> riba: because we don't want to implicitly depend on the host system
<marijnfs> daurnimator: wow that is weird indeed
<riba> daurnimator: i don't get it but i'm sure you have your reasons :D just needs to be documented somewhere then i think
<mq32> riba: it's quite sane for cross-platform-development not to rely on any system libraries
<marijnfs> dammn, I realised zmq provides c bindings to c++, so I also need libc++
<marijnfs> man these errors get cryptic, i guess it's hard to fix that
<daurnimator> marijnfs: are you statically linking or dynamically? if the former, yes you'll need to link all libraries of your dependencies, pkg-config usually helps here. but for a dynamic lib, you shouldn't need it
FireFox317 has quit [Remote host closed the connection]
<marijnfs> daurnimator: didn't set static linking explicitly, but did add linkSystemLibrary for the libraries
<daurnimator> marijnfs: ah looks like static is the default for executables
<daurnimator> marijnfs: however; linkSystemLibrary should use pkg-config to figure this out...
<daurnimator> marijnfs: at least on my system its called libzmq not zmq
<marijnfs> daurnimator: do you have examples of how to use pkg-config?
<daurnimator> marijnfs: e.g. `pkg-config --libs --static libzmq`
<marijnfs> interesting, do you call this stuff in a build.zig script?
<daurnimator> marijnfs: build.zig calls it for you
<daurnimator> though looking at the source of std/build.zig...... I think we don't pass --static?? that would be a bug to fi
<daurnimator> x
knebulae has quit [Read error: Connection reset by peer]
<marijnfs> daurnimator: I see, thats smart
<bgiannan> can't seem to find it http://releases.llvm.org/download.html#9.0.0
<dingenskirchen> that's the name of the clang folder
<dingenskirchen> dunno why though.
<daurnimator> I think its the "real" name of clang => C Front End
<daurnimator> e.g. the clang mailing list is cfe-dev
<marijnfs> bgiannan: i didn't need to add cfe
<marijnfs> but llvm didn't find the clang library initially during configuration, had to add in manually
<marijnfs> check if LLVM_EXTERNAL_CLANG_SOURCE_DIR is found
<marijnfs> how do i get the compiletime size of a string
<mq32> ("foo").len
<marijnfs> how do i get the compiletime size of a string
<marijnfs> woops
<marijnfs> mq32: thanks
<mq32> 1np
dingenskirchen has quit [Read error: Connection reset by peer]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
<marijnfs> how do i make a string literal look like []u8
<marijnfs> a found that making it const helps, but seems a bit hard to infer from expected type '[]u8', found '[11]u8
<marijnfs> a hint system for the compiler would be cool, like how clang++ gives suggestions when you screw up common cases
<marijnfs> I'm trying to make a function in build.zig that creates an executable and am trying to find the type of executable, but i see that addExecutable doesn't even define the return type. Is it infered?
keithdc has joined #zig
<daurnimator> marijnfs: []u8 is a slice (pointer + length). [11]u8 is an actual array
<marijnfs> daurnimator: I want to pass a ptr to the literal to C, so it needs to be ?*c_void
<marijnfs> how do i do that?
<daurnimator> marijnfs: address of operator (&) and then maybe a pointer cast?
<marijnfs> daurnimator: that seems to almost work, but it discards const qualifier
<marijnfs> ah found a hack, using ptrToInt and then intToPtr
wootehfoot has joined #zig
<bgiannan> huh llvm make install complaining about missing ocamldoc...
<mq32> oh wow. my GLes wrapper killes zig test :D
<bgiannan> guess i can build llvm without ocaml/go bindings
Ichorio has joined #zig
lunamn has joined #zig
keithdc has quit [Ping timeout: 240 seconds]
mahmudov has quit [Ping timeout: 240 seconds]
dimenus has joined #zig
<dimenus> does llvm have a standalone assembler (nasm syntax) or do you have to use clang?
_whitelogger has joined #zig
mahmudov has joined #zig
<riba> cimport ignores conditional macros
<riba> i defined the condition to be true using -D
<mq32> riba: @cImport({@cDefine("MY_COND",{}), @cHeader("foo.h") })
<riba> well actually it doesnt matter, it should be defined either way, just the definition is different
<riba> mq32: thanks, i'll try that
<mq32> riba, it depends on what it is defined to
<mq32> zig ignores a lot of more complex macro definitions
xyproto has left #zig ["WeeChat 2.6"]
<riba> mq32: that might be it then, that macro generates a function declaration and definition plus calls another macro
<riba> should --verbose-cimport output something in that case? because as far as i can see it doesn't
<mq32> i don't know
<mq32> but anything except for trivial macros is omitted
<mq32> (how should that be translated to zig anyways?)
tgschultz has quit [Ping timeout: 240 seconds]
tgschultz has joined #zig
<riba> a special inlining step?
<riba> alternatively remove "Zig is better at using C libraries than C is at using C libraries." from the introduction :P
<riba> not sure i can or want to duplicate glib macro logic for os-dependent things
<riba> or is stuff like __declspec(dllexport) unnecessary?
return0e_ has joined #zig
return0e has quit [Ping timeout: 265 seconds]
<mq32> __declspec(export) is just "export fn foo()"
<mq32> (if you want to export a fun)
<riba> i think that's what i wanna do, if i decoded this macro right
<riba> i'll see if it works
sossy has joined #zig
keithdc has joined #zig
Akuli has joined #zig
casaca has quit [Ping timeout: 268 seconds]
casaca has joined #zig
casaca has quit [Ping timeout: 265 seconds]
casaca has joined #zig
casaca has quit [Ping timeout: 240 seconds]
casaca has joined #zig
doublex_ has joined #zig
doublex has quit [Ping timeout: 245 seconds]
doublex_ has quit [Ping timeout: 240 seconds]
<marijnfs> @intToPtr(?*c_void, @ptrToInt(&buf)), is that really needed?
ForLoveOfCats has joined #zig
<marijnfs> to get a void*
<mq32> everytthing non-const should cast to c_void
<mq32> do you want to interface with C? what does the function do you want to call?
<marijnfs> it constructs a message struct, it takes the void* at the pointer to the data, another argument gives the size
<marijnfs> so now i use a zig string, and get the needed c_void pointer like that
<mq32> huh
<mq32> buf is the slice?
<mq32> just use buf.ptr
<mq32> then
<tgschultz> zig string doesn't end in null
<tgschultz> oh, it takes the size, nevermind
<marijnfs> using buf[0..].ptr complains about losing const qualifier
<marijnfs> I guess that makes sense
<marijnfs> but it's hard to cast that away
<marijnfs> maybe it would be nice to loosen requirements when talking to C, since it's often messy like this
halbeno has quit [Quit: Leaving.]
halbeno has joined #zig
<marijnfs> can i await on multiple frames? then take whichever is first?
<andrewrk> marijnfs, that abstraction is "select". It's one of the things that I tried to implement with old async/await here: https://github.com/ziglang/zig/blob/6f7939a452e69b77581f5390b8075e9dfa81b03e/lib/std/event/channel.zig#L150-L157
<andrewrk> now it's time to try to re-create this abstraction with the new async/await language features
<marijnfs> andrewrk: sweet
<muffindrake> I've not taken a look at async/await yet. Does that let me more easily work with blocking functions?
<andrewrk> muffindrake, if you mean non-blocking, then yes
<andrewrk> https://ziglang.org/documentation/master/std/#std;fs.Dir.open oops, dir.open can return error.IsDir
<andrewrk> I like how this error sets business exposes error codes that should not be
doublex has joined #zig
<ForLoveOfCats> I'm experiencing the build.zig for the zig0 0.5.0 compiler crashing while linking in `std.build.LibExeObjStep.linkSystemLibrary` by hitting the `else => unreachable,` on line 1841. Thowing a warn in there to log the error reveals that it's throwing an `error.StreamTooLong` while linking LLVM `LLVM-9`. The build previously succeeded with an earlier master in the lead up to 0.5.0 however there have been several system updates since
<ForLoveOfCats> then. I wanted to check here before opening a bug on GH.
<andrewrk> ForLoveOfCats, there were 2 fixes after 0.5.0 associated with this: https://github.com/ziglang/zig/issues/3415
<ForLoveOfCats> Glad it's known and handled! Cheers!
* daurnimator is currently at GSoC. Had a chat with a few zig targets including netbsd, freebsd and rtems. Hopefully they are interested and come on board to help us :)
utzig has joined #zig
sossy has quit [Ping timeout: 260 seconds]
<andrewrk> nice daurnimator!
<andrewrk> tell them to work on improving the widespread support of continuous integration services
<andrewrk> I mean, support for their OS on these services
reductum has joined #zig
<marler8997_> I remember it being ".zig-cache", but now it looks like it's "zig-cache"?
<marler8997_> Am I remembering wrong, or did it actually change?
<andrewrk> I don't think it was ever .zig-cache
<marler8997_> oh ok, weird
<nrdmn> I did some work on padding in std/fmt. I'm not sure if I'll find time to finish that
doublex has quit [Ping timeout: 250 seconds]
utzig has quit [Read error: Connection reset by peer]
doublex has joined #zig
utzig has joined #zig
utzig has quit [Read error: Connection reset by peer]
utzig has joined #zig
riba has quit [Ping timeout: 268 seconds]
cmrs has quit [Read error: Connection reset by peer]
ForLoveOfCats has quit [Quit: Konversation terminated!]
mahmudov has quit [Ping timeout: 268 seconds]
mahmudov has joined #zig
Akuli has quit [Quit: Leaving]
keithdc has quit [Ping timeout: 268 seconds]
utzig has quit [Read error: Connection reset by peer]
utzig has joined #zig
<marijnfs> can you get return types at comptime?
<marijnfs> my function should return whatever some specific functiohn returns
<wilsonk> marijnfs: I think tgshultz' pseudo_structs.txt might have touched on that: http://rants.tgschultz.com/A%20Brief%20Tour%20of%20the%20Comptime%20Pseudo-Struct.txt
<tgschultz> I think that might be much more complicated than what marijnfs is talking about. You can have the return type of a function be the result of a function call on any parameter passed to the function. `pub fn a(x: var) SpecialReturnType(@typeOf(x)) { ... }`
lunamn has quit [Ping timeout: 268 seconds]
lunamn has joined #zig
<tgschultz> so if you want the return type to match another function, you just need to use @typeInfo to inspect the function and get its return type. However, if that function is generic that won't work.
<mq32> tgschultz: probbaly just @typeOf(specificCall())
reductum has quit [Quit: WeeChat 2.6]
reductum has joined #zig
<wilsonk> ah, ok...I guess I was reading more into that than was needed
reductum has quit [Client Quit]
reductum has joined #zig
reductum has quit [Client Quit]
reductum has joined #zig
reductum has quit [Client Quit]
reductum has joined #zig
reductum has quit [Quit: WeeChat 2.6]
wootehfoot has quit [Read error: Connection reset by peer]
ntgg has joined #zig
<ntgg> is there a function that creates an iterator out of a slice?