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/
<tdeo> there's writeByteNTimes in std.io.Writer
<tdeo> i think the indenting stream isn't in std anymore
sebonirc has joined #zig
nycex has quit [Remote host closed the connection]
nycex has joined #zig
sebonirc has quit [Ping timeout: 246 seconds]
atkh has joined #zig
xackus__ has quit [Read error: Connection reset by peer]
xackus__ has joined #zig
notzmv has quit [Ping timeout: 264 seconds]
ur5us__ has joined #zig
ur5us_ has quit [Remote host closed the connection]
craigo has joined #zig
<mikdusan> re: zig-bootstrap: macos 10.13 cannot build with `zig cc/c++`; silent bad-linking with lld makes first-exec fail; and tried with no -target/-mcpu and at least this time bad-linking isn't silent. but in the end, same result: no joy. I think this has regressed.
jaens[m] has quit [*.net *.split]
BitPuffin has quit [*.net *.split]
watzon has quit [*.net *.split]
<andrewrk> bummer
<andrewrk> I'll look into reporting a release blocker for this
<mikdusan> I have one more thing to do before that if you don't mind
<mikdusan> i'll steal the zig-bootstrap HEAD build, and run it against llvm11 and zig master. if this succeeds, I'm more comfortable pointing at llvm12 as regression
watzon has joined #zig
jaens[m] has joined #zig
BitPuffin has joined #zig
nvmd has quit [Quit: Later nerds.]
brzg has joined #zig
sebonirc has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 264 seconds]
v0idify has joined #zig
ur5us__ has quit [Ping timeout: 260 seconds]
earnestly has quit [Ping timeout: 264 seconds]
brzg has quit [Quit: leaving]
leon-p has quit [Quit: leaving]
xackus__ has quit [Read error: Connection reset by peer]
xackus has joined #zig
zetta has joined #zig
v0idify has left #zig ["Leaving"]
xackus_ has joined #zig
xackus has quit [Ping timeout: 246 seconds]
ubert1 has quit [Ping timeout: 260 seconds]
ubert has joined #zig
ur5us has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
<siraben> anyone aware of compiling LLVM to Z80?
<yeti> I tried long ago and it lacked a linker back then. the same author has his LLVM in a different repo now but I don't know what might have improved and how it might relate to zig (if z80 is noe in LLVM's standard repo?)
ur5us has joined #zig
rxF is now known as torque
mmohammadi9812 has quit [Quit: Quit]
<mikdusan> llvmorg-12.0.0-rc3 tagged
<mikdusan> it has lemon's AArch64 f16 patch
ur5us has quit [Ping timeout: 245 seconds]
ur5us has joined #zig
ur5us has quit [Ping timeout: 245 seconds]
johannes has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
bitmapper has quit [Quit: Connection closed for inactivity]
sord937 has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
vegai has joined #zig
tnorth_ has joined #zig
ur5us has joined #zig
ur5us has quit [Ping timeout: 264 seconds]
cole-h has quit [Quit: Goodbye]
cole-h has joined #zig
zags has joined #zig
ubert has quit [Ping timeout: 260 seconds]
Pixeli has joined #zig
jokoon has joined #zig
earnestly has joined #zig
leon-p has joined #zig
xackus__ has joined #zig
posixlix has quit [Quit: Bridge terminating on SIGTERM]
kameliya[m] has quit [Quit: Bridge terminating on SIGTERM]
protheory8-new-m has quit [Quit: Bridge terminating on SIGTERM]
BitPuffin has quit [Quit: Bridge terminating on SIGTERM]
fengb has quit [Quit: Bridge terminating on SIGTERM]
ifreund_ has quit [Quit: Bridge terminating on SIGTERM]
siraben has quit [Quit: Bridge terminating on SIGTERM]
bitonic has quit [Quit: Bridge terminating on SIGTERM]
leibniz[m] has quit [Quit: Bridge terminating on SIGTERM]
watzon has quit [Quit: Bridge terminating on SIGTERM]
jaens[m] has quit [Quit: Bridge terminating on SIGTERM]
tjammer[m] has quit [Quit: Bridge terminating on SIGTERM]
Nypsie[m] has quit [Quit: Bridge terminating on SIGTERM]
ugla has quit [Quit: Bridge terminating on SIGTERM]
Snektron has quit [Quit: Bridge terminating on SIGTERM]
xackus_ has quit [Ping timeout: 245 seconds]
posixlix has joined #zig
ugla has joined #zig
leibniz[m] has joined #zig
kameliya[m] has joined #zig
siraben has joined #zig
ifreund_ has joined #zig
bitonic has joined #zig
jaens[m] has joined #zig
protheory8-new-m has joined #zig
Nypsie[m] has joined #zig
tjammer[m] has joined #zig
fengb has joined #zig
Snektron has joined #zig
watzon has joined #zig
ubert has joined #zig
Raito_Bezarius has quit [Ping timeout: 240 seconds]
Raito_Bezarius has joined #zig
xackus__ has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
jokoon has quit [Quit: Leaving]
sundbp has joined #zig
sundbp has quit [Quit: Connection closed]
shadeops has quit [Ping timeout: 276 seconds]
waleee-cl has joined #zig
dch has quit []
dch has joined #zig
notzmv has joined #zig
xackus_ has quit [Read error: Connection reset by peer]
layneson has joined #zig
notzmv has quit [Ping timeout: 272 seconds]
talin has quit [Quit: leaving]
<Raito_Bezarius> is there something I can do to make myself compatible with std.debug in my environment (preboot UEFI) ?
nvmd has joined #zig
Pixeli has quit [Ping timeout: 260 seconds]
dch has quit []
dch has joined #zig
zags has quit [Ping timeout: 246 seconds]
drsensor90 has joined #zig
drsensor90 has left #zig [#zig]
drsensor has joined #zig
superdump has joined #zig
johannes has quit [Ping timeout: 264 seconds]
<superdump> i just watched a video about zig from 2018 and at the end, during the Q&A, someone asked what people you were looking for to get involved. one section mentioned game developers to perhaps implement something like GLFW/SDL that is nice to use in zig. did anyone show up and do that? what windowing / input libraries are available that you might recommend looking at? also, is there a good place to look for zig libraries?
<superdump> i've been writing a lot of rust in my spare time, and i really like having cargo and crates.io. i appreciate that that would / could be considered significant feature creep for zig and so you may not want to deal with it. still, perhaps someone else has done it already...?
<dutchie> package manager is next on the list after the self-hosted compiler has done, though there have been a lot of discussions about its design already
zags has joined #zig
<dutchie> there are a few out there already, e.g. https://github.com/mattnite/gyro https://github.com/nektro/zigmod
<dutchie> i don't know about windowing/input/etc i'm afraid
zags has quit [Ping timeout: 256 seconds]
zags has joined #zig
danyspin97 has joined #zig
<danyspin97> I am starting a new project in zig
<danyspin97> should I use master or 0.7.1 version?
<danyspin97> I haven't followed the development much lately :(
<ikskuh> i would use master
<ikskuh> as there is a release pretty soon(ish)
<danyspin97> nice, thaks!
<danyspin97> thanks*
<g-w1> will it be at the same time as llvm 12?
xackus has joined #zig
<Nypsie> Usually a little after (2-4 weeks depending on bugs)
<tnorth_> Hello, is there a way to prevent zig test to consume std.debug.print() messages? It would be nice for testing (during dev) to be able to print out some values
<g-w1> what do you mean with consume?
<tnorth_> they are not displayed on stdout/stderr
<g-w1> maybe try std.log.something?
<g-w1> I think it redirects it though
<semarie> \n at end of line ? it could depend how the buffering is done
<tnorth_> semarie: oh that works indeed
<tnorth_> thanks
notzmv has joined #zig
zags has quit [Ping timeout: 276 seconds]
<g-w1> you can use std.log.something also since it auto inserts \n
<tnorth_> g-w1: ok I didn't know that, thanks
xentec has quit [Quit: memento mori]
xentec has joined #zig
zags has joined #zig
xentec has quit [Client Quit]
xentec has joined #zig
xentec has quit [Max SendQ exceeded]
xentec has joined #zig
xentec has quit [Max SendQ exceeded]
xentec has joined #zig
enedil has joined #zig
bitmapper has joined #zig
fputs has joined #zig
<enedil> Hello, I searched a bit and I didn't find an answer. I get this error: `expected type '*c_void', found '?[]align(4096) u8'`. How can I cast it? I need to return a *c_void, as it is a function to be used from C
<enedil> I'm beginner to Zig, sorry if it's obvious
Akuli has joined #zig
bbuccianti has quit [Quit: ZNC 1.8.2 - https://znc.in]
drsensor has quit [Quit: Connection closed for inactivity]
bbuccianti has joined #zig
<danyspin97> can I compile a zig program from within a zig executable?
<danyspin97> i.e. have the build step inside a zig source file
<g-w1> you mean use the compiler as a library?
<danyspin97> yea
<g-w1> no
<g-w1> you could invoke zig on the cli
<danyspin97> i have to pass a lot of compile time switches
<danyspin97> so using it as libray would have been better
<ifreund> are you aware of the zig build system?
<danyspin97> ifreund: do you mean the internals or the build.zig?
<g-w1> what is your use case?
<ifreund> ^^^^
<danyspin97> generating an initramfs
<danyspin97> there is a bootstrap.zig that gets compiled and a init.zig that remains as source
<danyspin97> the bootstrap program creates an init executable based on some options and generate an ad-hoc executable
<g-w1> is this at build-time?
<danyspin97> not at zig build time
<danyspin97> but later
<g-w1> maybe you could use the std.build still? not sure
<danyspin97> yea, that's what I hope
<danyspin97> the shared libraries to use depends on arguments to the bootstrap executable
<g-w1> what time is it built? at compile time or runtime?
<g-w1> because maybe you could make it a different step in build.zig?
<danyspin97> runtime then
<s-ol> if I allocate using const x = allocator.alloc(T, 5), can I shrink that slice and free it e.g. with allocator.free(x[0..3]) ?
<s-ol> or is the allocator allowed to actually use the length of the passed slice
<ifreund> s-ol: the allocator does use the length of the slice
craigo has quit [Ping timeout: 265 seconds]
<s-ol> ok, thanks
shadeops has joined #zig
enedil has left #zig [#zig]
txdv has joined #zig
<txdv> Hi guys, how do I convert []u8 to [c*]const u8?
notzmv has quit [Ping timeout: 265 seconds]
riba has joined #zig
<g-w1> maybe the slice.ptr?
<g-w1> if that does not work try @ptrCast([c*]const u8, slice.ptr)
<ifreund> slice.ptr works
<ifreund> if C expect the pointer to be null-terminated you may need to take extra steps though
<txdv> other languages support embedding null into the string "x: {} y: {} \0"
<g-w1> you want \x00 for null
<ifreund> txdv: also, string literals in zig are null terminated by default
<ifreund> they are of type *const [N:0]u8
<ifreund> where N is the length
<txdv> i'm using bufPrint on a predefined fixed sized buffer
<ifreund> txdv: bufPrintZ
tnorth_ has quit [Ping timeout: 260 seconds]
FrancescoAlem has joined #zig
<FrancescoAlem> Hallo!!
<ifreund> o7
<txdv> Hallo
<FrancescoAlem> First time in this chat, and also just learned about Zig yesterday
<g-w1> niice! hello
<FrancescoAlem> What brought you guys to Zig?
<txdv> Cross compilation to like everything
<g-w1> readability
layneson has quit [Ping timeout: 264 seconds]
zags has quit [Ping timeout: 260 seconds]
<FrancescoAlem> Both seem like excellent points :D, I already watched that talk, it was extremely fun and interesting
<FrancescoAlem> I'm having a tough time learning how to leverage the std-lib, are there guides focusing on using Arrays HashMaps and Data Structures, and maybe creating them?
<Gliptic> FrancescoAlem: https://ziglearn.org/chapter-2/ is pretty good
<FrancescoAlem> Thank you! Didnt know that website :)
<txdv> Also I like that you can just include C libs and access them without the need for writing this translation layer
<ifreund> I wanted to write a wayland compositor but didn't really want to maintain a large C codebase and rust wasn't an option because I wanted to use wlroots
<shadeops> I've just started learning as well (as part of club at work where everyone picks a different lang to solve a problem). In addition to ziglearn.org, I've learned a lot just by reading the tests within the std-lib. For example: https://github.com/ziglang/zig/blob/a033735c8d2faf4ecd42b9d736d8ea61d22d3fcb/lib/std/hash_map.zig#L811
<txdv> like in C# or Crystal where you to define the C interface with the language constructs provided by the language
<txdv> or worse, Java, which has this awkward jni or jna library
<ifreund> Zig is perfect as it's a huge step up in safety over C while having the best C interoperation I've had the pleasure to use
<g-w1> +1 for reading the stdlib tests
<FrancescoAlem> Recently I got interested again in low level languages, so I subscribed to exercism, and I did the rust track... And very soon I learned that Rust promise of safe low level code is a big lie ahahah, as soon as I read the Zig manifesto, and the comptime features I was hooked.
<ifreund> Good zig bindings are strictly better than the C APIs they wrap
<ifreund> assuming the api doesn't rely on stupid macro shit
<Gliptic> big lie?
<ifreund> low level code is inherently unsafe
<ifreund> rust is about building abstractions over that
r4pr0n has joined #zig
<ifreund> which in my experience causes much more fricition than it's worth and causes tons of accidental complexity
<ifreund> also unsafe rust is waaay more unsafe than C in a lot of ways
<companion_cube> is it? :)
<companion_cube> (more limited, I'd say, tbh)
<ifreund> companion_cube: there's no spec, and most of the conversation I see about unsafe rust is debates about whether something is UB or not
<ifreund> it's also several orders of magnitude more complex than C
<companion_cube> just like C, but there's a spec-ish (the rustonomicon)
<FrancescoAlem> Exactly ifreund that is what I meant with 'big lie', at some point (in Rust) you start writing extremely involved code simply because the compiler will not accept safe solutions that do not adhere to the rust model of memory management
<companion_cube> doesn't seem to be more language lawyering than in C
<companion_cube> (the tricky part imho is that RAII becomes dangerous when you have pointers)
<ifreund> you always have pointers in low level code
<companion_cube> FrancescoAlem: sometimes you can use a tiny bit of unsafe and it works well
<companion_cube> (I have a rust codebase where there's one unsafe to keep 2 &mut inside the same array)
<companion_cube> the rest is safe 🤷
<Gliptic> 2 &mut to the same thing?
<companion_cube> to different slots of the same array
<companion_cube> (with a `assert_ne!(i,j)` for the indexes, just to be sure :p)
<Gliptic> split_mut_at not good enough? :)
<Gliptic> *split_at_mut
<Gliptic> I guess it's a specialized version of that
<companion_cube> yeah
<companion_cube> simpler to do a bit of unsafe than to dance with split_mut_at :p
<ifreund> just wait till the cargo geiger crowds finds your project :P
<companion_cube> heh, yeah… let them come ⚔
r4pr0n has quit [Remote host closed the connection]
r4pr0n has joined #zig
wilsonk_ has joined #zig
<fengb> ... I was trying to click that x
hspak3 has joined #zig
isolier7 has joined #zig
lunamn8 has joined #zig
sawzall has joined #zig
rowbee has joined #zig
chivay_ has joined #zig
idxu_ has joined #zig
notzmv has joined #zig
timmydo_ has joined #zig
evbo has joined #zig
iceball has joined #zig
<txdv> How do I force a conversion from c_int to u8?
<g-w1> @truncate
<ifreund> or @intCast() depending on what behavior you want
lunamn8 has quit [Quit: o/ https://thelounge.lasagna.dev]
semarie_ has joined #zig
semarie_ is now known as semarie
semarie has quit [Killed (kornbluth.freenode.net (Nickname regained by services))]
<ifreund> is the c_int guarenteed to fit inside the u8?
<ifreund> the value of the c_int I mean
<txdv> @intCast to convert c_int to u32 and then @truncate
fputs has quit [*.net *.split]
Akuli has quit [*.net *.split]
wilsonk has quit [*.net *.split]
isolier has quit [*.net *.split]
idxu has quit [*.net *.split]
hspak has quit [*.net *.split]
lunamn has quit [*.net *.split]
LanceThePants has quit [*.net *.split]
timmydo has quit [*.net *.split]
amk has quit [*.net *.split]
companion_cube has quit [*.net *.split]
chivay has quit [*.net *.split]
rohb has quit [*.net *.split]
bsrd has quit [*.net *.split]
bens has quit [*.net *.split]
idxu_ is now known as idxu
hspak3 is now known as hspak
isolier7 is now known as isolier
amk has joined #zig
<txdv> This is actually nice that these separate and not like in C
lunamn has joined #zig
notzmv has quit [Ping timeout: 264 seconds]
<ifreund> why the two steps?
<ifreund> the difference is that if you do it that way, you won't get a panic in safe build modes if the c_int's value is positive but greater than 255
<txdv> I like it that these are two separate steps
<g-w1> I think it 1
companion_cube has joined #zig
Akuli has joined #zig
<companion_cube> ifreund: I think rust is good for "systems" that is not that low level (i.e. not really touching hardware stuff, say)
<companion_cube> more like high performance database, networking, tools… but not necessarily a bootloader
ratfactor has joined #zig
<txdv> with C you have segfaults all the time, with zig it seems like it is not the case
<g-w1> you can, but you understand a lot more why you get them
gazler_ has quit [Quit: Leaving]
<txdv> How is this construct called: struct { buffer: [1024]u8, pub fn func() u8 { ... } } ?
<g-w1> the struct or the function on it?
<txdv> the function on it
<g-w1> I like to call it a method but zig calls it a BoundFn formally
<txdv> Not much about BoundFn in the docs
<g-w1> its not that complicated. if you call it on an instance of a struct it does @TypeOf(s).funcname(s) iirc and if called on a type, well that is self explanitory you just dom96 StructType.funcname()
<g-w1> s/dom96/do
sord937 has quit [Quit: sord937]
txdv has quit [Quit: Connection closed]
ratfactor has quit [Quit: Connection closed]
zupss has quit []
zags has joined #zig
leah2 has quit [Ping timeout: 264 seconds]
ur5us has joined #zig
leah2 has joined #zig
zags has quit [Ping timeout: 264 seconds]
dfacto has quit [Quit: The Lounge - https://thelounge.chat]
skuzzymiglet has quit [Remote host closed the connection]
skuzzymiglet has joined #zig
dfacto has joined #zig
tdeo has quit [Read error: Connection reset by peer]
tdeo has joined #zig
leon-p has quit [Quit: leaving]
leon-p has joined #zig
notzmv has joined #zig
riba has quit [Ping timeout: 264 seconds]
mikdusan has quit [Quit: WeeChat 3.0.1]
zags has joined #zig
evbo is now known as fputs
zags_ has joined #zig
ubert has quit [Ping timeout: 268 seconds]
zags has quit [Ping timeout: 264 seconds]
dputtick has quit []
dputtick has joined #zig
nikki93 has quit []
nikki93 has joined #zig
r4pr0n has quit [Quit: r4pr0n]
xackus has quit [Ping timeout: 256 seconds]
mikdusan has joined #zig
Akuli has quit [Quit: Leaving]
<vent> How can I coerce a []const u8 to a []u8, so that I can pass it as an argument that's expecting a []u8?
<ikskuh> you cannot
<ikskuh> "[]const u8" means that the memory is immutable
<ikskuh> (at least for you)
<ikskuh> and []u8 requires mutable memory
<ikskuh> so you either need to dupe the memory with something (local array, allocator, ...)
tomku has quit [Quit: Lost terminal]
<vent> Ah, that makes sense. Maybe that's not my problem then. Basically, I want my function to take in a []u8, so that I can mutate the data in-place. However, when I try and pass in a string that I've declared with `var`, the compiler complains about recieving a `*const [5:0]u8` instead of a `[]u8`.
<ikskuh> yep
<ikskuh> var str = "foo";
<ikskuh> is only a pointer
<ikskuh> if you check the type of str with @compileLog(@TypeOf(str))
<ikskuh> you see that it is
<ikskuh> var str: *const [3:0]u8 = "foo";
<vent> Ah, and so it's the pointer that's var? Not the data it's pointing to?
<ikskuh> yep
<ikskuh> the string is still constant memor
<kameliya[m]> yep. you can change what the var points to, but not what it's pointing to (since its type is a const pointer)
<ikskuh> you can do this:
<ikskuh> var str_buf: [3]u8 = "foo".*; // dereference!
zags_ has quit [Ping timeout: 264 seconds]
<vent> Okay, so I've initialized it using that ^. However, it seems that I'm still not able to mutate the string contents from inside of the function I'm passing the string to. Here's what I've got: http://ix.io/2SoO
<ikskuh> you now don't have a pointer anymore (msg isn't a pointer but an array value)
<ikskuh> so you need to pass &msg
<vent> Oh woops, there was an error in there that I missed when simplifying my code, try refreshing that if you haven't already
<vent> Okay, so I'm passing in &msg, and I've changed the parameter to `*[5]u8`.
<ikskuh> nah, just keep []u8 as the parameter type :)
<ikskuh> pointer-to-array coerces to slice
<vent> Hmmm, still the same error message. "Cannot assign to constant"
<kameliya[m]> on which line? maybe a pointer needed in the for loop?
<kameliya[m]> like `for (msg) |*c| { c.* += 15; }`
<ikskuh> ^
ur5us has quit [Ping timeout: 264 seconds]
<vent> Oh the line where I'm incrementing `c` by 15
<vent> Yep, that did it!
<kameliya[m]> nice!
<vent> Fantastic stuff. Yeah, pointer in the for loop, and dereferencing `c` works. Thanks ikskuh and kameliya[m]!
<ikskuh> vent: what is your background and what brought you to zig?
<vent> I'm coming from mostly Rust and C++, bit of C, and some embedded Rust/C.
<ikskuh> ah, so Zig should be a quite enjoyable experience then :)
<vent> I decided to learn Zig only a day or so ago, I'm loving it so far. I liked using C a lot, and as far as I can tell Zig seems to have all of the benefits of C without any of the drawbacks.
<ikskuh> yep!
<ikskuh> zig is really well-designed :)
<vent> It's really great, the metaprogramming is so cool. I love how the refined it all is. What would be several different systems in other languages (core languge, generics, macros, the build system, etc...) are all just one system in Zig. It's great.
<ifreund> and it's not even 1.0 yet, things will get even better :)
<andrewrk> there has been an explosion of interest in the last week, it's been a wild ride
<ikskuh> what ifreund says
<vent> Only thing I'm kind of missing are ranges like you'd get in Rust, something like: (1..=100). Not sure if that's missing from the language or not.
<vent> Since with those, syntax like this would be pretty handy and readable: http://ix.io/2SoS
<vent> Whereas as I currently understand it, you'd use a while loop. Which leaves the index on it's own line and in the same scope as the while loop. Correct me if I'm wrong though!
<kameliya[m]> indeed -- this kind of thing comes up fairly often in discussions (lots of issues, e.g. https://github.com/ziglang/zig/issues/5070 https://github.com/ziglang/zig/issues/3110 https://github.com/ziglang/zig/issues/7826)
<kameliya[m]> nothing settled yet
<kameliya[m]> and yes, you got that right.
<vent> Ah, yeah I actually read through those 2 issues when looking this up. Hopefully something will be added before 1.0. I think if the implementation of ranges is too tricky, memory-wise, I think a way to initialize your index in the same scope as a while loop would go a long way.
<kameliya[m]> yeah, agreed! it would clean up a lot of code, i think.
<vent> But besides that, I'm loving the language. Need to get back into the rhythm of doing things in a C-like way though, as you can probably tell! I've been too privileged by Rust recently, and I'm a bit rusty on my C skills.
<vent> That pun was not indended ^