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/
karrick has joined #zig
karrick has quit [Remote host closed the connection]
karrick has joined #zig
karrick has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
karrick has joined #zig
karrick has quit [Remote host closed the connection]
<Snektron> <fengb "I type everything perfectly the "> Programming russian roulette
ur5us has joined #zig
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
karrick has joined #zig
spenced has joined #zig
_whitelogger has joined #zig
return0e has quit []
swoogan has joined #zig
zippoh has joined #zig
mahmudov has quit [Ping timeout: 240 seconds]
mahmudov has joined #zig
spenced has left #zig ["https://quassel-irc.org - Chat comfortably. Anywhere."]
mahmudov has quit [Read error: Connection reset by peer]
mahmudov has joined #zig
Guest65855 has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 260 seconds]
swoogan has quit [Ping timeout: 260 seconds]
dddddd has quit [Remote host closed the connection]
<daurnimator> https://drewdevault.com/2020/01/08/Re-Slow.html "Wow, Zig is competitive with assembly?"
mahmudov has quit [Remote host closed the connection]
ltriant has quit [Quit: leaving]
<fengb> "It’s not likely to replace C for me, but it might have a place somewhere in my stack." I wonder why
adamkowalski has joined #zig
schme245 has joined #zig
adamkowalski has quit [Remote host closed the connection]
presiden has left #zig ["WeeChat 2.7"]
return0e has joined #zig
return0e has quit [Ping timeout: 260 seconds]
schme245 has quit [Remote host closed the connection]
return0e has joined #zig
SimonNa has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
ur5us has joined #zig
return0e_ has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #zig
marmotini_ has quit [Read error: Connection reset by peer]
schme245 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
marmotini_ has joined #zig
lunamn has joined #zig
marmotini_ has quit [Remote host closed the connection]
lunamn has quit [Ping timeout: 260 seconds]
lunamn_ has joined #zig
dddddd has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
Astronothing has joined #zig
squeek502 has joined #zig
squeek_ has quit [Ping timeout: 265 seconds]
return0e_ has quit [Remote host closed the connection]
phillyiscool has joined #zig
<phillyiscool> Is there an equivalent of `void *` in Zig? I would like to have a struct field that can accept any struct type.
<phillyiscool> I guess the expectation is to use generics instead of having void * fields
phillyiscool has quit [Remote host closed the connection]
schme245 has quit [Remote host closed the connection]
schme245 has joined #zig
<scientes> ph...ahh they always leave before they get an answer...
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
schme245 has quit [Remote host closed the connection]
phillyiscool has joined #zig
phillyiscool has quit [Remote host closed the connection]
_Vi has quit [Ping timeout: 260 seconds]
Guest65855 has joined #zig
<Astronothing> I wouldn't mind getting the answer
Guest65855 is now known as dimenus
<scientes> Astronothing use [*]u8 or []u8
<scientes> depending if you want a length
<mattmurr> How are they different?
<scientes> [*]u8 is a pointer, and []u8 is a slice, so a pointer and a length
<Astronothing> scientes would I be able to convert [*]u8 to a pointer of a different type?
<scientes> the * means the length is unknown
<scientes> using @ptrCast
<Astronothing> ok, thanks
<mattmurr> makes sense now 🙂 ty
bheads has quit [Quit: bheads]
bheads has joined #zig
<SyrupThinker> Wouldn't *@OpaqueType() be the bettet Pointer because one cannot misinterpret it?
<mq32> SyrupThinker: "const Handle = *OpaqueType();" is a common pattern to address a "unique, but incomplete" type
<scientes> SyrupThinker, @OpaqueType is just for compatibility with C, where it is possible to have a header define a type that doesn't have a known length
<fengb> Opaque is generally used for “this is a known type but I don’t know what’s in it”
<scientes> it also is limited, cause you can't add methods to it
<scientes> which is annoying when trying to zigify a C library
<SyrupThinker> All the things I'd want from a void pointer
<scientes> void * is differen't
<scientes> cause it doesn't have a type
<scientes> its the ANY type
<scientes> but just use what ANSI C uses, char *, or [*]u8
<fengb> Opaque wasn't designed to hold "any type" but instead for "forward declared struct pointers"
<SyrupThinker> I think it is bad idea to use a pointer that can be dereferenced if its supposed to represent another type.
_Vi has joined #zig
<fengb> How about... *c_void? :P
<scientes> SyrupThinker, zig isn't trying to tell you what to do
<scientes> that is the C++ madness rabbit hole
<SyrupThinker> fengb: Eh, good enough I guess, makes the intend more clear when one knows C
<fengb> C++ gives you 5 different incompatible ropes
<scientes> you mean nooses?
<fengb> And one of those was introduced as the latest gold standard
<fengb> I don't think I've seen any Zig code that literally means "any type" so I'm not sure what the convention should be
<SyrupThinker> scientes: I am aware, my point was just that using a pointer to OpaqueType forces a pointer case to use any data, forcing the user to think
<fengb> Most of those cases in C are generics, which is better with comptime comparisons
<SyrupThinker> *cast
<scientes> fengb, well, these are all byte machines, so [*]u8 with appropiate alignment is what I would use...
<scientes> no reason to be as complicated as C
<fengb> I do agree with SyrupThinker that communicating intent is important
<scientes> yeah, but we don't want inheritable types
<scientes> which is what he is asking for
<scientes> or rather we don't have them
<fengb> My usual response to that is: issue 130, gonna avoid an internet argument >_>
<SyrupThinker> I do not believe I asked for that
<SyrupThinker> Because I have no use for them
<scientes> i'm just pointing out that this specific thing has a clear abstraction
<scientes> and I'd rather not support just one instance of it
return0e_ has joined #zig
<SyrupThinker> Alright, just wanted to have some opinion on that, thanks for responding
mgxm has quit [Quit: ....]
<mq32> what's the correct type if i want to export a "void * " handle? jus use void * ?
mgxm has joined #zig
nocko` has joined #zig
<mq32> huh
<mq32> seems like get_c_type cannot translate function pointers?
<scientes> and my patch to support vectors on that never got merged....
<mq32> pub const umqttAllocator = extern struct { alloc: extern fn () c_int, };
<mq32> that struct doesn't translate.. .(
<nocko`> I'm new to zig and trying to write a high-level wrapper for the init_module syscall. I'm using the std.os.linux sources as a guide, but I cannot seem to make a parameter of the sentinel-terminated pointer type.
<nocko`> pub fn insmod(buf: []const u8, args: [*:0]const u8) !void {
<scientes> nocko`, init_module?
<scientes> oh, syscall
<nocko`> The compiler gives me: error: invalid character: ':'
<nocko`> pub fn insmod(buf: []const u8, args: [*:0]const u8) !void {
<nocko`> This seems to be the pattern in the std sources...
<scientes> nocko`, is this just for fund? cause you realize libkmod was created not that long ago to solve all the problems with the old modprobe
<scientes> *fun
<scientes> also, you probably want finit_module()
<nocko`> The project is a statically linked app to unlock mtd and update bootloader on embedded linux. I'm embedding the ko and the new flash contents.
<scientes> why can't you just statically link libkmod?
<scientes> but yeah, that seems reasonable
<nocko`> It's quite possible that I could, maybe overkill for one syscall. I'm secondarily intereseted in why I can't declare a function with a parameter that matches the stdlib.
<nocko`> The entire function is:
<nocko`> pub fn insmod(buf: []const u8, args: [*:0]const u8) !void {
<nocko`> std.debug.warn("Loading Module\n");
<nocko`> var r = std.os.linux.syscall3(
<nocko`> std.os.linux.SYS_init_module, @ptrToInt(&buf), buf.len, @ptrToInt(args));
<nocko`> if (r != 0) {
<nocko`> return MtdError.InsmodFailed
<nocko`> }
<nocko`> }
<nocko`> Ugh, should have done a gist, or similar.
<scientes> yeah buf could just be a @includeFile too
<scientes> which is super slick
<fengb> Are you using the nightly build? Sentinel termination was introduced recently
<scientes> yeah, you use to need c"" to get null termination
<nocko`> 0.5.0
<scientes> yeah switch to master
<nocko`> Ugh. What a dumb error on my part.
<nocko`> Thanks.
FireFox317 has joined #zig
<fengb> We get that every other day. User problems are usually UX problems :P
<scientes> nocko`, also once you get it working, submit a PR with the usable stuff
<FireFox317> nocko: I think the problem is that you are using zig 0.5.0 and the docs you are reading are from master
<FireFox317> nocko`: pointers is something that was added after 0.5.0
<FireFox317> sentinel-terminated pointers*
<nocko`> I was reading the correct documentation, but when I went diving into the stdlib for inspiration I was browsing the master branch.
* nocko` facepalm
<scientes> probably just use master for now
<nocko`> Building master now. Thanks again for the hint. It would have taken me a fair amount more time to discover this on my own.
<fengb> There's also a nightly package at the top of https://ziglang.org/download/
<nocko`> non-variadic std.debug.warn feels clunky. Probably I should stop being lazy and use better output apis...
<nocko`> ooh, but output while building libc is very nice!
<scientes> nocko`, yeah i just ran into that
<scientes> i couldn't even get std.debug.warn to work...
<mikdusan> andrewrk: I'm still working on adding an arena allocator to stage1; would like to know if it's a big no-no to use constructors/destructors? eg. I have coded an ArenaList to replace ZigList but it needs to be associated with an arena instance
FireFox317 has quit [Remote host closed the connection]
<pixelherodev> "Zig requires LLVM to be built with all default targets enabled." There a way to deliberately work around this and only build native compilation?
<pixelherodev> Otherwise I'm going to be held up for a few hours recompiling LLVM :P
* pixelherodev sighs in pain
schme245 has joined #zig
<pixelherodev> Guess I'll update LLVM/Clang to 9.0.1 while I'm at it
<scientes> pixelherodev, yeah the in-tree build was also rejected, which adds even more pain
<scientes> when doing something that requires modifying both
<scientes> or when doing a bisection
<leeward> I ran `zig build test-std` with a test in heap/logging_allocator.zig and it didn't get run. The same test in heap.zig did execute (and fail, correctly). Is there something I have to do to add a file to the set of files with tests?
<pixelherodev> Does zig at least support LLVM 10?
<pixelherodev> If so, might as well jump to 10 so I can start working on AVR
<scientes> master is on 9
<pixelherodev> Drats
<scientes> 9 works on avr
<pixelherodev> What?
<scientes> I think....
<pixelherodev> Hmm... not on Gentoo...
<leeward> Oh, does 10 have good AVR support?
<leeward> 9's is...not great.
<scientes> pixelherodev, you just have to turn it on
<pixelherodev> Nah, I mean it's not an option
<scientes> oh , it was out of tree?
<pixelherodev> Gentoo doesn't have it as an option until LLVM 10
<scientes> anyways, gcc's avr was always better
<pixelherodev> Sure, but that doesn't work with Zig
<pixelherodev> Unless LLVM has a secret GIMPLE backend
<scientes> pixelherodev, noone wants to maintain such a thing
<scientes> in either direction
<pixelherodev> shocker
<pixelherodev> Would be neat to have bidirectional translation though
<pixelherodev> I'd be interested in seeing what could be done optimization-wise then
<leeward> It would give LLVM languages like Zig and Rust instant support for so many platforms.
<leeward> How many people out there really want to maintain an ARC compiler?
dimenus has quit [Remote host closed the connection]
<leeward> https://dragonegg.llvm.org/ does exist, but it goes the wrong way.
<pixelherodev> GIMPLE -> LLVM?
<leeward> yeah
<leeward> It's an LLVM backend for GCC.
schme245 has quit [Remote host closed the connection]
schme245 has joined #zig
<pixelherodev> Yeah, but it's also extremely outdated
<pixelherodev> LLVM 3.3 is the last supported release AFAICT
<leeward> That's your thing about nobody being interested in maintaining it.
<leeward> I'm not really sure why it exists. All of LLVM's target platforms are supported by GCC, and the optimizer isn't so much better that I'd stick something like that in the loop.
<fengb> LLVM originated as a backend for GCC before it got frontends
<leeward> Maybe GCC didn't support LTO when it existed?
<leeward> I guess that would do it.
schme245 has quit [Ping timeout: 260 seconds]
<mikdusan> leeward: "Is there something I have to do to add a file to the set of files with tests?" <-- did you solve this yet?
<leeward> mikdusan: nope
<mikdusan> take a look at lib/std/crypto.zig, last block
<mikdusan> that's how you tie-in tests from sub-dirs
<scientes> is there any good reason to have llvm have a slice type?
<scientes> I dont think so
<leeward> mikdusan: Ah, thanks.
Astronothing has quit [Ping timeout: 258 seconds]
return0e_ has quit [Remote host closed the connection]
<leeward> Looks like daurnimator beat me to the punch, and taught be about a feature I hadn't noticed in the process.
Snetry has quit [Ping timeout: 265 seconds]
<leeward> s/be/me/
Snetry has joined #zig
Astronothing has joined #zig
bheads has quit [Ping timeout: 258 seconds]
_Vi has quit [Ping timeout: 268 seconds]
Astronothing has quit [Ping timeout: 260 seconds]
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
adamkowalski has joined #zig
Akuli has joined #zig
SimonNa has joined #zig
Snetry is now known as Sentry
Sentry is now known as Snetry
waleee-cl has joined #zig
wootehfoot has joined #zig
bheads has joined #zig
adamkowalski has quit [Quit: Lost terminal]
adamkowalski has joined #zig
<frmdstryr> comptime const state_field = ascii.toLower(name) ++ "_state"
<frmdstryr> error: expected type 'u8', found '[]const u8'
<frmdstryr> Is there any way to tell it to just copy the bytes at comptime?
<frmdstryr> like a comptime allocator
<pixelherodev> Alrighty, Zig fixed. Yay!
<pixelherodev> That only took... 2 hours?
<pixelherodev> Of course, now Clang needs a rebuild, but ZIg seems fine for now
<pixelherodev> There a way to remove the lib prefix from generated libraries?
_Vi has joined #zig
<andrewrk> pixelherodev, no but https://github.com/ziglang/zig/issues/2279 is accepted now
<pixelherodev> Well, I guess I can just do a `mv` in the makefile
<pixelherodev> That issue looks simple enough to implement... if I have time this weekend, I'll tackle that
<frmdstryr> That works, thanks!
GrooveStomp has joined #zig
<leeward> scientes: I guess that LLVM/GCC integration thing didn't pan out.
<scientes> leeward, that was 2005
<leeward> I noticed.
<scientes> i just sent you it so you could understand the history a little better
<leeward> The proposal there was to use LLVM's LTO with GCC, which was still pondering the idea at the time.
<scientes> that is more an excuse
<scientes> the real proposal is for apple not to have to spend all the money to develop clang
<fengb> Didn't Lattner/Apple want more flexible integration and GNU said no help for proprietary software?
<leeward> It's not proprietary software, and they floated the idea of assigning copyright to the FSF.
<leeward> Or are you talking about the software Apple was building with it?
<scientes> leeward, you can build propiatary software with gcc
<leeward> I know.
<fengb> Yeah, Apple hired Lattner to work on compilers. That eventually led to inhouse Clang
<fengb> I don't think that was the original intention but then a pissing contest involved :P
<fengb> I can't English
<BaroqueLarouche> since GCC changed to GPL3, corporations become hesistant to use it
<scientes> fengb, he also got hired right after GPL3 came out, and gcc immediately switched
pmwhite1 has joined #zig
<scientes> that said, LLVM does have a better architecture, even if the code is so-so
<BaroqueLarouche> on PS3 for instance, the GCC version was stuck to the last GCC version using GPL2.
<leeward> I don't see the problem with GPLv3 for GCC as long as it has the same exceptions to GPLv2 that it had before.
<scientes> I don't say that lightly
<scientes> gcc and llvm both have their advantages
<lupine> in fairness, destroy all proprietary software
<pixelherodev> There a reason a `fn` isn't the same as an `extern fn`?
<BaroqueLarouche> extern fn makes the function uses the C ABI
<leeward> I think that compilers as a whole are better off for there being competition.
<pixelherodev> Ah
<scientes> BaroqueLarouche, except that the PS3 doesn't ship gcc, so the gpl3 anti-tivo clause doesn't apply
<scientes> BaroqueLarouche, same in regards to android
<BaroqueLarouche> sorry mixing it up with export
<pixelherodev> Yeah that's what I thought
<scientes> (although i believe android is entirely built with llvm/clang these days)
<pixelherodev> Using a C import
<pixelherodev> Which uses function pointers
<BaroqueLarouche> Android has moved to clang
<pixelherodev> And apparently ` = struct{fn func...}.func` isn't good enough
<leeward> lupine: Hard to justify not letting people license the software they write the way they want.
<pixelherodev> Does work with exported function though
<lupine> nah
<lupine> morality is good like that
<leeward> I don't see the moral superiority of denying people options.
<fengb> I've heard that GCC is intentionally architected poorly to prevent proprietary extensions
* lupine denies leeward the option to kill lots of other people
<lupine> oh how immoral of me
<leeward> Ok, so you're comparing shipping binary-only software to killing people now?
<companion_cube> I heard the same, so they've brought llvm on themselves
<lupine> yeah
<lupine> we're not going to get this to a reasonable level of complexity without destroying this channel, so let's leave it
<leeward> Good point.
<leeward> Also, fengb, I hadn't heard that, but it sounds like a joke.
<companion_cube> nah, they explicitely didn't want gcc to have an API
<mikdusan> fengb: I heard they intentionally kept GIMPLE undocumented and opaque
<pixelherodev> argh - `Generate .h...TODO implement get_c_type for more types`
<pixelherodev> and then a crash
<pixelherodev> I don't even need a .h!
<leeward> Whoopsie.
<pixelherodev> Oh right --disable-gen-h
<leeward> Don't expect it to get a lot better before self-hosted is a thing, pixelherodev.
<pixelherodev> Yeah, it's fine
<pixelherodev> Yay, plugin building is working now!
<leeward> \o/
pmwhite1 is now known as pmwhite
<mikdusan> frmdstryr: I added a variation on that code - apparently you can deref a string literal to get at the array literal if desired. https://hastebin.com/iqotakumov.js
<frmdstryr> Won't that modify the original then? I need both
<mikdusan> yes. just saying if you needed a buffer and not orig.
<frmdstryr> Gotcha, both are useful, so thanks for sharing
GrooveStomp has quit [Quit: GrooveStomp]
mahmudov has joined #zig
marmotini_ has joined #zig
mahmudov has quit [Ping timeout: 268 seconds]
marmotini_ has quit [Remote host closed the connection]
schme245 has joined #zig
mahmudov has joined #zig
<pixelherodev> Huh
<pixelherodev> Zig just, oddly, started only compiling needed parts of libc
<pixelherodev> It's actually fast now
schme245 has quit [Remote host closed the connection]
ur5us has joined #zig
nullheroes has quit [Quit: WeeChat 2.5]
Akuli has quit [Quit: Leaving]
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
doublex has quit [Ping timeout: 260 seconds]
<fengb> leeward: finally found a source about LLVM vs GCC: https://www.phoronix.com/scan.php?page=news_item&px=MTU4MzE
<fengb> Also https://lwn.net/Articles/629259/ but this happened much later
doublex has joined #zig
mahmudov has quit [Read error: Connection reset by peer]
<terinjokes> is there a correct way to import from lib/os/bits from a user program?
<terinjokes> i'm currently thunking a syscall with asm myself (and I do plan on sending a PR to add it to the os package), but was hoping for a "correct" way to do it in the meantime
<pixelherodev> Uh
<pixelherodev> That should already be in std.os
<pixelherodev> Anything in std.os.bits should be
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
dingenskirchen1 is now known as dingenskirchen
mahmudov has joined #zig
mahmudov has quit [Read error: Connection reset by peer]
waleee-cl has quit [Quit: Connection closed for inactivity]
<daurnimator> leeward: I beat you when/how?
ltriant has joined #zig
<terinjokes> pixelherodev: I do see the usingnamespace to import it, and I can see the SYS_ cnstants on std.os. I don't however see std.os.syscall4, which I would expect
<daurnimator> terinjokes: that's under e.g. std.os.linux.syscall4
<daurnimator> which syscall are you missing anyway?
<terinjokes> ahh, excellent! I'm still getting used to reading zig code. i see this is exported on line 31 of os.zig
<terinjokes> on linux I'm using sendfile/sendfile64. I wouldn't mind trying my hand at sending a PR adding it to std
mahmudov has joined #zig