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/
lunamn has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
_whitelogger has joined #zig
ntgg has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
marijnfs__ has joined #zig
marijnfs_ has quit [Ping timeout: 246 seconds]
return0e_ has joined #zig
return0e has quit [Ping timeout: 246 seconds]
return0e_ has quit [Ping timeout: 245 seconds]
return0e has joined #zig
karrick_ has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
karrick_ has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
nglicophik has joined #zig
nglicophik has quit [Ping timeout: 248 seconds]
rjtobin has joined #zig
kristoff_it has joined #zig
belgin has joined #zig
<belgin> why hello there
<belgin> does zig work without llvm?
<diltsman> Zig uses LLVM as the backend to do optimization and code generation.
kristoff_it has quit [Ping timeout: 246 seconds]
<belgin> are you planning on implementing zig's own backend?
<diltsman> I doubt that there are plans for that as that is a huge undertaking to make one that generates good code. andrewrk would know better than I do.
<hryx> hi belgin, welcome. right now zig depends on LLVM 100%. zig may add additional backends that LLVM doesn't have in the future -- that has been discussed a bit
<diltsman> Besides, using LLVM as a backend means that code generation is supported for any target that LLVM has.
<belgin> ok thanks
<hryx> belgin: if you have a use case for not using LLVM, of course please do share -- the community is often very interested in addressing less common cases
<laaron> hi, zig not use system libc on my archlinux default. I found argument `--libc [file]`, but what is the file format?
<emekankurumeh[m]> you can use `zig libc > libc.txt` to get a libc file
<belgin> hryx, llvm is slow
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
<belgin> i guess it's too early to consider compilation speed at this point, but i suggest it's a nice thing to keep in mind
<hryx> belgin: slow compared to what?
<hryx> additionally LLVM supports a large number of targets, which is an important goal for zig
<belgin> i was compiling a small zig program and it took like 2 seconds on debug, even with the cache thingy
<belgin> but maybe a 1mloc program will also take 2 seconds, in which case it's ok
<hryx> fast debug builds are a goal of zig's. do you have a link to your program (and maybe your hardware)?
<belgin> that's cool! let me see if i can reproduce it
<belgin> oh yeah, i've been meaning to ask, do i need visual studio to run zig on windows?
<hryx> good question - I think emekankurumeh[m] can help answer that. there has been a lot of work this week on mingw-w64 (I'm not totally sure if that would affect it)
<laaron> thanks, i got a syslibc.cfg, but when use `--libc syslibc.cfg`, seems no affect, the executable binary still a static linked.
<belgin> laaron, have you tried putting the .so of the libc in there?
<andrewrk> laaron, what is your system libc?
<laaron> glibc, install via package manager
<andrewrk> belgin, no you do not need msvc to run zig on windows
<belgin> thanks
<laaron> belgin, no custom libc.so, it in default search path /usr/lib/libc.so, i think
<belgin> hryx, i can't reproduce it, sorry for wasting your time
<belgin> it's under a second now
GrooveStomp has joined #zig
<andrewrk> laaron, can you test something for me? `llc --version | grep Default`
<andrewrk> llc would be provided from an llvm package
<laaron> andrewrk, result: Default target: x86_64-pc-linux-gnu
<andrewrk> but now I wonder if arch has patched llvm to make this so, or if a source build would do the same thing
<andrewrk> laaron, and `zig targets | grep native` ?
kristoff_it has joined #zig
<laaron> x86_64 (native)
<laaron> linux (native)
<laaron> gnu (native)
<laaron> 2.17 (native)
<laaron> x86_64-linux-gnu (native)
<andrewrk> ok zig is correctly identifying glibc as your target. you must be saying that 2.17 is incorrect, yes?
<andrewrk> hmm no you said that the binary is statically linked. I don't understand how this would be
<andrewrk> oh, are you linking against libc? zig does not link against libc by default
<andrewrk> can I see your build.zig or your zig command line?
<laaron> when zig will link against libc, this maybe the problem, my code is simple empty, `const std = @import("std"); pub fn main() void {}`
<andrewrk> laaron, this program has no dependency on libc
<andrewrk> if you wish to force it, you may do so with `--library c`
kristoff_it has quit [Ping timeout: 244 seconds]
<laaron> i see, thanks. another error when use `--library c`
<laaron> full command: `zig build-exe --libc ./syslibc.cfg -dynamic --verbose-link --verbose-cc --cache off --library c a.zig`
<laaron> lld: error: unable to find library -lgcc
<hryx> belgin: hey no worries at all
kristoff_it has joined #zig
<andrewrk> laaron, the --libc advice was incorrect
<belgin> hey, andrewrk, i just wanted to say your talk at the recurse center has been very inspirational for me, thank you for opening my eyes
<andrewrk> sorry, I mean, you do not need --libc
<andrewrk> also don't pass -dynamic or --cache off
<andrewrk> why are you overriding all these defaults? the defaults are good
<andrewrk> `zig build-exe a.zig` is correct
kristoff_it has quit [Ping timeout: 258 seconds]
<andrewrk> if you want it to be linked against libc for some reason (why?), `zig build-exe a.zig --library c`
<andrewrk> thanks belgin
<andrewrk> there is a second talk
<andrewrk> if you're interested
<belgin> i know, i haven't seen that one yet
<laaron> yeap, works. only `--libc` and `--library c` conflict
<laaron> so i think it's mean `--libc` for custom libc, `--library c-or-other` for system libraries, right?
<andrewrk> correct
rjtobin has quit [Quit: Leaving]
_whitelogger has joined #zig
kristoff_it has joined #zig
<wilsonk__> andrewrk: how do you emit .ll code again? -mllvm -emit-llvm doesn't seem to work
kristoff_it has quit [Ping timeout: 268 seconds]
<wilsonk__> hmm, or maybe you aren't on anymore...kinda late Friday over there ;)
<daurnimator> andrewrk: hmm? why not the shortening feature? (it's in the same message as the title, so its not like it's an extra message)
<wilsonk__> oh, nvm I suppose -emit-llvm-ir is the correct option. my bad
<daurnimator> fgenesis: why do you get pinged?
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
GrooveStomp has quit [Ping timeout: 272 seconds]
MH026 has quit [Remote host closed the connection]
<hryx> the URL shortening is both unexpected and perhaps a minor privacy violation: it sends your text to a third party service (is.gd) automatically without consent. I think users on chat could be rightly surprised by that
<hryx> as for "pinging" I think the bot makes some kind of announcement type post. a screenshot of an iOS client that might demonstrate: https://www.dropbox.com/s/skumercv34e6ezk/2019-07-12%2023.17.15.jpg?dl=0
<[[]]> h​ryx: Title "Dropbox - 2019-07-12 23.17.15.jpg - Simplify your life" Shortened < https://is.gd/j7t4nt >
<daurnimator> hryx: it's a "Notice" (rather than a privmsg), as they are usually *quieter* and used by bots so they don't get in a cycle
<daurnimator> hryx: also logs for this channel are public :P
<hryx> I know. to me the behavior was still surprising
return0e has quit []
knebulae has quit [Read error: Connection reset by peer]
MH026 has joined #zig
return0e has joined #zig
return0e has quit []
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
return0e has joined #zig
jjido has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
belgin has quit [Quit: Leaving]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MH026 has quit [Remote host closed the connection]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
jjido has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
brakmic has joined #zig
kristoff_it has joined #zig
brakmic has quit [Read error: Connection reset by peer]
brakmic has joined #zig
brakmic has quit [Client Quit]
brakmic has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
kristoff_it has joined #zig
marijnfs has joined #zig
knebulae has joined #zig
very-mediocre has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
very-mediocre has quit [Read error: Connection reset by peer]
marijnfs has quit [Quit: WeeChat 2.4]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
marijnfs has joined #zig
andersfr has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
<andersfr> how do I make a pull request? I have my changes committed in a local branch but no permissions to submit anything to github...
nifker has joined #zig
nifker was banned on #zig by ChanServ [*!*@x5d83458f.dyn.telefonica.de]
nifker was kicked from #zig by ChanServ [Banned: disrespect !T 1w]
very-mediocre1 has joined #zig
<emekankurumeh[m]> first you make a fork of the zig repo
<andersfr> Having to fork to do a pull request seems retarded. But apparently that is the only thing GitHub supports :(
very-mediocre1 has quit [Read error: Connection reset by peer]
ffddr has joined #zig
kristoff_it has joined #zig
very-mediocre has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
andersfr has quit [Remote host closed the connection]
andersfr has joined #zig
<ffddr> https://github.com/ziglang/zig/issues/1031#issuecomment-393606730 is `([]u8)(&pip)[0..1]` correct way to make []u8 from a struct? I got compilation error `error: expected type '[]u8', found '*const type'` :(
<[[]]> f​fddr: Title "C interoperability: zero-init and partial initialization for imported C structs? · Issue #1031 · ziglang/zig · GitHub" Shortened < https://is.gd/eIvBNi >
<ffddr> oh, sorry, wrong error, actual one is `error: expected type '[]u8', found '*.cimport:1:20.struct_lws_context_creation_info'`
<mikdusan> ffddr: maybe `mem.toBytes()` ?
<ffddr> mikdusan it looks like toBytes returns a copy of the input, not the pointer valid for memset
<ffddr> hm, but `asBytes` is probably the thing I am looking for!
<ffddr> yes, it looks like it works, thanks again! `std.mem.set(u8, std.mem.asBytes(&info), 0);`
andersfr has quit []
ffddr has quit [Remote host closed the connection]
ffddr has joined #zig
jjido has joined #zig
kristoff_it has joined #zig
ffddr15 has joined #zig
<emekankurumeh[m]> perhaps we should change men.set to take a var parameter?
kristoff_it has quit [Ping timeout: 246 seconds]
ffddr15 has quit [Remote host closed the connection]
ffddr20 has joined #zig
ffddr20 has quit [Remote host closed the connection]
ffddr46 has joined #zig
ffddr has quit [Ping timeout: 244 seconds]
ffddr46 has quit [Ping timeout: 245 seconds]
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre has joined #zig
shritesh has joined #zig
ffddr has joined #zig
husho has joined #zig
<ffddr> Is there any way to zero initialize struct on comptime?
Ichorio has joined #zig
<via> i feel like i'm going crazy, but is there something very wrong about what i'm doing here? https://gist.github.com/via/1bd5854801b7cfe986c37d16d20fee68
[[]] has quit [Remote host closed the connection]
[[]] has joined #zig
<via> stepping through with gdb, i can see the prints doing std.mem.copy's of the bytes, and the outstream pos gets incremented, the outstream's slice len gets incremented, but nothing gets put into the slice but nulls
<marijnfs> maybe resetting the stream resets everything?
andersfr has joined #zig
<marijnfs> just guessing
<via> it just sets pos=0, but it doesn't matter, i do the printing after the reset
<via> i mean by the time it gets to the warn()ing of the slice, its just null bytes. even stepping through the print() function, once its done with output(), the slice bytes are null (but len incremented)
<mikdusan> `ret.buf = undefined` then what does `ret.buf[0..]` mean?
Tetralux_ has joined #zig
<ffddr> Came up to this https://pastebin.com/ezCKHKDc for comptime zeroes init Oo
<[[]]> f​fddr: Title "const TypeId = @import(\"builtin\").TypeId; fn init_zeroes(comptime T: type) T - Pastebin.com" Shortened < https://is.gd/2olPjx >
<Tetralux_> via: ret.buf is undefined isn't it?
Tetralux has quit [Ping timeout: 248 seconds]
Tetralux_ is now known as Tetralux
<via> but its an array, its just the bytes that are undefined, right?
<Tetralux> via: Ah yeah.
<via> i suppose i'm also asking, is this the right way to instantiate that struct -- buf is allocated as part of the struct on the stack of the caller to init(), right?
<via> it has a stack-looking address in gdb
<Tetralux> Yeah - [N]T arrays are inline to the struct.
<Tetralux> So @sizeOf(Console) should be > 1024.
<ffddr> maybe there is some better way to get zero initialzied struct in comptime?
<Tetralux> ffddr: Give all fields a default value of zero and then use const x = T{};
<Tetralux> i.e: Same as C++... :")
<ffddr> Tetralux unfortunately its C struct came from .h file, some of them are quite large
<Tetralux> If you use an editor with multiple cursors, you could match the ':' for each field and type it that way.
<Tetralux> Or, you can memset.
<Tetralux> You can't memset a Zig struct apparently because of hidden safety stuff
<Tetralux> But you can an extern struct I believe
<via> i'm not really sure that the undefined assignments are the issue here -- i was using more or less the same process with a buf and SliceOutStream successfully before moving it into a struct
<ffddr> Hm, could I? I tried but it always crashed the compiler - I guess its because I cant use pointers on comptime
<Tetralux> via: Yeah - I don't think it should be.
<Tetralux> via: But it's not clear to me what the problem is from a cursory glance.
<via> i'll gist some gdb output to make the weirdness more clear
<andrewrk> andersfr, you can also send patches to the mailing list. the "retard" comment is not appreciated
<husho> can zig compiler compile c++ code?
<Tetralux> husho: With libclang IIRC.
<andrewrk> husho, I have not put testing into compiling C++ code but it should work
<Tetralux> Oh my bad - read that as "how can" xD
<andrewrk> eventually we plan to support it for self-hosting: https://github.com/ziglang/zig/issues/853
<[[]]> a​ndrewrk: Title "The Grand Bootstrapping Plan · Issue #853 · ziglang/zig · GitHub" Shortened < https://is.gd/3Oqlng >
<via> okay, so clearly something weird is going on with my second print: https://gist.github.com/via/ff9b7e39b183feb41e731150fb5b6b63
<[[]]> v​ia: Title "gist:ff9b7e39b183feb41e731150fb5b6b63 · GitHub" Shortened < https://is.gd/UqtWZy >
<andersfr> @andrewrk: sorry about the bad language. I forked and created the PR as was suggested
<andrewrk> thanks!
<andersfr> btw is there any way to detect availability of SSE instructions?
<via> it looks to me like my slice is getting clobbered somewhere in SliceOutStream https://gist.github.com/via/15ebaf533a677cb4058da45d63cedbf8
<[[]]> v​ia: Title "gist:15ebaf533a677cb4058da45d63cedbf8 · GitHub" Shortened < https://is.gd/QcM0Yk >
Ichorio has quit [Ping timeout: 264 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ffddr has quit [Remote host closed the connection]
<mikdusan> via: i think issue is that init uses a stack var for console and outstream stores a slice (pointer) to that buffer
<via> i was assuming that the struct (and thus buf?) was allocated on the caller's stack frame, though if not that would make sense
<via> whats the best way to do what i'm doing? using an allocator doesn't feel like it should be necessary, i want it stack allocated
<via> that also seems like a pretty easy thing to do without realizing it if so, it'd be great if the compiler would catch that, thats very unsafe
kristoff_it has joined #zig
<mikdusan> i can't answer for best; need to find a place after init() to initialize outstream. 2-stage init. or if your process() is a 1-time gig, put it before outstream.reset()
very-mediocre has quit [Read error: Connection reset by peer]
<andrewrk> andersfr, good question. there is currently not but that is now planned
<andrewrk> andersfr, in general @import("builtin") has all the information about the target, and it's missing that information, but should be added
<andrewrk> you can see the contents with `zig builtin`
very-mediocre has joined #zig
<andrewrk> I'll make an issue
<[[]]> m​ikdusan: Title "via.zig · GitHub" Shortened < https://is.gd/lVdJVE >
<andersfr> I think it should be possible to determine the level of support as well. Pretty sure LLVM exposes this in its target information
kristoff_it has quit [Ping timeout: 245 seconds]
<andrewrk> what does that mean, level of support?
<via> mikdusan: i guess i'm confused as to why that would be different -- the space for both buf and the stream are allocated as part of the struct. init() for the stream isn't actually allocating anything right?
<andrewrk> andersfr, here's an issue for this: https://github.com/ziglang/zig/issues/2883
<[[]]> a​ndrewrk: Title "ability to specify target CPU features · Issue #2883 · ziglang/zig · GitHub" Shortened < https://is.gd/MIMrtS >
<andersfr> andrewrk looks good
<mikdusan> via: SliceOutStream stores a pointer to `init()` stack frame `ret.buf`; then it is returned, and the frame vanishes. yet outstream still has that pointer.
<via> is ret.buf not the Console struct's buf?
<mikdusan> via: i'll add comment to your gist in a moment...
<via> i suppose, when you slicify an array, does that do a stack frame allocation of the slice's metadata? and if so, i'm wondering if there's a way to do this in init(). especially since there's room for the slice in the stream in my struct
<via> i imagine i could directly assign outstream.slice, but that feels super hacky
<mikdusan> via: i added comment to your orig gist. that's my understanding of the issue.
<via> yeah, the reason i am structuring it this way in the first place is because of the lack of that feature you're referring to for the time being
<mikdusan> yup!
<via> but still, there's got to be a way to do this with just my Console init() function, without having to do the slice creation in main or process
<mikdusan> i guess you could change the nature of init() and pass it a pointer. so callsite does `var console: Console = undefined; console.init();` as now it has a pointer to its storage.
<via> is there any plan for the compiler to be aware of (and error for) returning pointers to stuff allocated on the stack like that?
<mikdusan> i think there is an issue discussing that. let me see if i can find it
<mikdusan> via: this one is about having access to result-location (eg. from inside init()): https://github.com/ziglang/zig/issues/2765
<[[]]> m​ikdusan: Title "result location: ability to refer to the return result location before the `return` statement · Issue #2765 · ziglang/zig · GitHub" Shortened < https://is.gd/kTk4g6 >
<via> mikdusan: so if thats the issue, then why wouldn't this work? https://gist.github.com/via/5601df999e08953ab65d597db4cb792f
<[[]]> v​ia: Title "gist:5601df999e08953ab65d597db4cb792f · GitHub" Shortened < https://is.gd/60TbRH >
<via> e.g. store a slice in the struct too
<mikdusan> because no matter what, `ret` and field `ret.buf` is on init() stack frame.
<via> but if i understand the issues, its all about doing copy elision instead of what i assume is currently a memcpy? if not, i don't understand how pretty much half the std library works, its all about returning structs from init
<via> init isn't returning a pointer to a struct, its returning something that i assume gets copied into the caller's stack allocated struct
<mikdusan> most of std library init()'s do a `return SomeType { ... };` directly and this is copy-elided. but putting it in a stack var first, then returning that var, you end up copying from stack-var to call-site storage.
<via> yeah, but point is its still copied
<via> so i get that its not optimal, but it should still work
<andrewrk> also note that it probably gets elided in optimized builds, but zig can't guarantee that according to the semantics (until that linked issue is solved)
<mikdusan> i'm piss poor at explaining things; but maybe this helps. this would be bad: `var buf: [1024]u8 = undefined; var p = &buf; return p;` because we let the address of stack storage escape
<mikdusan> and that's essentially what is happening with your code
<via> sure, but in that gist i pasted, "p" is in the struct
<via> and i'm returning the struct, which should get copied in entirety (buf, _buf, outstream, byte for byte) right?
<via> oh, i guess _buf would be pointing to the stack allocated one, and not the destination one -_-
<mikdusan> outstream.slice.ptr will be copied. and so will _buf.ptr
<mikdusan> right
<mikdusan> this kind of issue only comes up with you have a self-referential struct
<mikdusan> *when
<via> well, bummer. thank you
andersfr has quit []
very-mediocre has quit [Read error: Connection reset by peer]
very-mediocre has joined #zig
kristoff_it has joined #zig
Akuli has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
commander has joined #zig
ffddr has joined #zig
<ffddr> what does this `error: cast discards const qualifier` error means in the context of function pointer cast? I got it from `@ptrCast([*c]lws_callback_function, callback_http);`.
shritesh has quit []
brakmic has quit [Read error: Connection reset by peer]
<andrewrk> don't cast something to a C pointer
<andrewrk> there's never a reason to do that
<ffddr> I need to pass a function pointer to a struct with `callback: [*c]lws_callback_function`
brakmic has joined #zig
brakmic has quit [Client Quit]
<[[]]> a​ndrewrk: Title "Documentation - The Zig Programming Language" Shortened < https://is.gd/W4or6Z >
brakmic has joined #zig
brakmic has quit [Client Quit]
<andrewrk> what error do you get when you directly pass `callback_http`?
brakmic has joined #zig
<ffddr> error: expected type '[*c]extern fn(?*.cimport:1:20.struct_lws, .cimport:1:20.enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int', found 'fn(?*.cimport:1:20.struct_lws, .cimport:1:20.enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int' p.callback = callback_http;
<andrewrk> you're missing `extern` on your callback function
<ffddr> `error: expected type '[*c]extern fn(?*.cimport:1:20.struct_lws, .cimport:1:20.enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int', found 'extern fn(?*.cimport:1:20.struct_lws, .cimport:1:20.enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int'`
brakmic has quit [Client Quit]
brakmic has joined #zig
<ffddr> `p.callback = &@ptrCast(lws_callback_function, callback_http);` <- this compiles, but looks like its pointer of a pointer :(
<ffddr> `p.callback = @intToPtr([*c]lws_callback_function, @ptrToInt(callback_http));` works (and callback is actually callable), but it doesnt work on compiletime (not sure that it could)
<andrewrk> [*c]extern fn (...) is a double pointer, which seems like something got translated incorrectly
<andrewrk> do you know where this type is declared in the .h file?
<andrewrk> I'm trying to find it in https://github.com/warmcat/libwebsockets
<[[]]> a​ndrewrk: Title "GitHub - warmcat/libwebsockets: canonical libwebsockets.org websocket library" Shortened < https://is.gd/hUmf4u >
<andrewrk> found it
<andrewrk> what type is `p` in your example
<ffddr> ` var p: lws_protocols`
very-mediocre has quit [Read error: Connection reset by peer]
<[[]]> a​ndrewrk: Shortened < https://is.gd/wQI1nP >
<andrewrk> I need to double check what this C code even means, is that a double pointer or not? I'm not sure
<andrewrk> you can see the simpler struct field got translated as expected
<ffddr> I am not sure about everything in C to be honest, but I thought its a single function pointer.
<andrewrk> a workaround for this, is to indeed use @ptrCast but you still do not need C pointers
<ffddr> hm, from the C usage code: https://github.com/apaulin/ChatChannel/blob/1636d24242acaecbbca15e7f2fc583f698b11b42/websocketserver/server.c#L86 it looks like its a double pointer(still not sure)
<[[]]> f​fddr: Title "ChatChannel/server.c at 1636d24242acaecbbca15e7f2fc583f698b11b42 · apaulin/ChatChannel · GitHub" Shortened < https://is.gd/Y7gFq4 >
<ffddr> like, funciton name is a first pointer and they use it with &
<andrewrk> workaround: p.callback_http = @ptrCast(*extern fn(?*struct_lws, enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int, callback_http);
<ffddr> `error: cast discards const qualifier` :(
nifker1 has joined #zig
nifker1 was kicked from #zig by ChanServ [Banned: disrespect !T 1w]
<[[]]> a​ndrewrk: Title "incorrectly translated double function pointer · Issue #2887 · ziglang/zig · GitHub" Shortened < https://is.gd/qa2GCT >
<andrewrk> workaround: p.callback_http = @ptrCast(*const extern fn(?*struct_lws, enum_lws_callback_reasons, ?*c_void, ?*c_void, usize) c_int, callback_http);
<ffddr> still that const qualifier error
kristoff_it has joined #zig
<andrewrk> oh, right, the problem is that the destination type is incorrect
<andrewrk> this needs to be fixed in translate-c
<[[]]> f​fddr: Title "libwebsockets/vhost.c at 3c1eb97537b41d615f52bc2965c54df661381a6b · warmcat/libwebsockets · GitHub" Shortened < https://is.gd/BuD1ay >
kristoff_it has quit [Ping timeout: 244 seconds]
<ffddr> Hm, why I can @ptrCast on comptime, but cant @ptrToInt?
<andrewrk> ffddr, I pushed c0489abcdba to master to fix this
<ffddr> wow!
<ffddr> @ptrToInt hack is not needed anymore, but I am still trying to figure out why I cant store pointer as int on comptime? the error: `error: cannot store runtime value in compile time variable`
<andrewrk> is the pointer address known at comptime?
<andrewrk> for global variables and functions the address is computed during linking, so it can participate in some comptime expressions, but the integer value is not available for comptime computations
<ffddr> actually I am not sure, its that extern fn pointer. But I thought that @ptrCast and @ptrToInt have same restrictions
<andrewrk> this sounds like an issue that will be resolved by https://github.com/ziglang/zig/issues/2174
<[[]]> a​ndrewrk: Title "introduce \"lazy values\" concept to fix false positive dependency loops · Issue #2174 · ziglang/zig · GitHub" Shortened < https://is.gd/wBgbOx >
<ffddr> ` p.callback = callback_http;` it works now!
<andrewrk> good
<fgenesis> 07:30 < daurnimator> fgenesis: why do you get pinged?
<fgenesis> my client (irssi) triggers a hilight every time the bot sends a message like this
<ffddr> I think I got the difference between @ptrCast and @ptrToInt - @ptrCast can be somehow lazy evaluated with link-time known variables, while @intToPtr cant, right?
<fgenesis> maybe because it's this out-of-channel message style, dunno
MH026 has joined #zig
<andrewrk> ffddr, right
<andrewrk> well even @intToPtr can get a bit lazier
<ffddr> wow, it all really works, that callback is actually receiving some network messages! Thanks again :)
<andrewrk> great, happy hacking
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
rjtobin has joined #zig
ffddr has quit [Remote host closed the connection]
very-mediocre has joined #zig
andersfr has joined #zig
andersfr has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
tgschultz has quit [Ping timeout: 252 seconds]
tgschultz has joined #zig
andersfr has joined #zig
tgschultz has quit [Ping timeout: 268 seconds]
tgschultz has joined #zig
very-mediocre has quit [Read error: Connection reset by peer]
kristoff_it has joined #zig
very-mediocre has joined #zig
andersfr has quit [Remote host closed the connection]
kristoff_it has quit [Ping timeout: 245 seconds]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 245 seconds]
MajorLag has quit [Ping timeout: 244 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
kristoff_it has joined #zig
andersfr has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
andersfr has quit [Remote host closed the connection]
very-mediocre has quit [Read error: Connection reset by peer]
andersfr has joined #zig
brakmic has quit [Read error: Connection reset by peer]
brakmic_ has joined #zig
andersfr has quit [Ping timeout: 246 seconds]
andersfr has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
mikdusan has quit [Ping timeout: 245 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
very-mediocre has joined #zig
MajorLag has joined #zig
MajorLag is now known as tgschultz
kristoff_it has joined #zig
very-mediocre has left #zig [#zig]
kristoff_it has quit [Ping timeout: 248 seconds]
Akuli has quit [Quit: Leaving]
kristoff_it has joined #zig
<emekankurumeh[m]> andrewrk: is segfault safety enabled for stage0?
kristoff_it has quit [Ping timeout: 246 seconds]
laaron- has joined #zig
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
ntgg has joined #zig
brakmic_ has quit [Ping timeout: 245 seconds]
<ntgg> I want to use https://github.com/Hejsil/zig-clap do I just clone the directory to somewhere on my computer then do exe.addPackagePath(...) or is there a better way to do this?
<[[]]> n​tgg: Title "GitHub - Hejsil/zig-clap: Simple command line argument parsing library" Shortened < https://is.gd/ZjG2PJ >
<emekankurumeh[m]> that's the status quo, but a package manger is planned.
<Tetralux> I'd suggest you make a vendor dir in your project and put it in there.
<Tetralux> Usually the simplest.
<[[]]> e​mekankurumeh[m]: Title "package manager · Issue #943 · ziglang/zig · GitHub" Shortened < https://is.gd/AAf0gy >
<ntgg> thanks!
jjido has joined #zig
brakmic has joined #zig
<hryx> is there already an issue/proposal for supporting implicitly casting between struct types?
<emekankurumeh[m]> i don't think so
<hryx> ok. I was looking at the anonymous struct literal issue, and I think it's a related issue
<hryx> but not necessarily a blocker
<emekankurumeh[m]> but i think a feature like nim's converters might be nice for that
<emekankurumeh[m]> thought that breaks one of the zens of zig :/
<hryx> never heard of "converters" - I'll have to look that up
<emekankurumeh[m]> basically they are functions that the nim runtime will insert implicit calls to in order to implement implicit casts
<emekankurumeh[m]> it allows users to define their own implicit casts
<[[]]> e​mekankurumeh[m]: Title "Nim Manual" Shortened < https://is.gd/99p9TD >
ntgg has quit [Ping timeout: 272 seconds]
ntgg has joined #zig
ntgg has quit [Ping timeout: 268 seconds]
nifker has joined #zig
nifker was kicked from #zig by ChanServ [Banned: disrespect !T 1w]
andersfr has quit []
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
kristoff_it has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ltr- has joined #zig
Cadey has joined #zig
brakmic has quit []
<hryx> damn. just spent a while working on a struct casting proposal, but I think it's flawed
kristoff_it has quit [Ping timeout: 248 seconds]
<scientes> heh, it took andrew 3 trys to get something on copy elision
<hryx> The only real use case I had was supporting int/float literals in anonymous struct literals. But I'm pretty sure that's already inherently covered in that proposal
<hryx> scientes: what do you mean? you mean iterating over the proposal?
<scientes> i'm just saying you don't have to succeed every time
<hryx> true :>
<hryx> But I think my original idea isn't fundamentally justifiable, nor necessary
<hryx> Looking back, I think my proposal boils down to "make structs totally duck typed". which is cool, but I don't see a real use case for it yet
<hryx> and it has tons of problems to work out
<scientes> ewwww
<scientes> well I would have to see it
<scientes> do you mean structs, or stuct literals?
<hryx> scientes: I'll make a gist and post it here, even though I don't like it anymore
<scientes> so the unicode literals patch is stalled because the compiler is crashing
<[[]]> s​cientes: Title "GitHub - shawnl/zig at utf8-less" Shortened < https://is.gd/0T9HQ0 >
<hryx> scientes: here you go, let me know if there's anything in here that you find potentially valuable: https://gist.github.com/hryx/7fa554be42c7241c8b2392c3d6693b31
<[[]]> h​ryx: Title "A somewhat misguided proposal · GitHub" Shortened < https://is.gd/97hKdB >
tgschultz has quit [Remote host closed the connection]
<scientes> yeah I think that is a bad idea
<hryx> scientes: I'll never get used to the poop emoji
<scientes> if you even need that you can write a function to do it explicitely
<scientes> hell, what you have there can even be done with generics
<hryx> of course. did you read the Alternatives section?
<scientes> it doesn't need to be part of the language
<scientes> no i didn't make it that far :)
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
<hryx> ok. I appreciate your input, but it's a little hurtful to say my proposal is a bad idea without having read it
<scientes> i read half way through
<scientes> I'm sorry
<scientes> how about @bitCast() on structs?
<scientes> which would be similar to an extern union
<scientes> and I have personally run across the casting of fields issue
<scientes> which is quite annoying
<hryx> my main concern would be about how the order/adding of fields isn't guaranteed, so @bitCast on structs might have undefined results
<scientes> it would only work on extern structs
<scientes> *which would be the same as an extern union
<scientes> it would be the same as doing a pointer-cast thingy
<scientes> as well
<scientes> (because we don't have strict aliasing)