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> does anyone understand this C warning? https://godbolt.org/z/bYYjcq
<leah2> remove the & tho
<ikskuh> andrewrk: you're taking a "pointer-pointer" there, so you receive a pointer to an array instead of letting the array decay into the correct pointer type
<andrewrk> I don't think it's a pointer pointer
<leah2> but removing the & fixes it ;)
<leah2> and that makes "it a pointer fewer"
<ikskuh> andrewrk: yeah, that's why i quoted it :D
<ikskuh> you get a pointer to an array though
<ikskuh> instead of a pointer to the first element
<andrewrk> but I want a pointer to an array
<andrewrk> and puts also wants a pointer to an array
<ikskuh> puts wants a pointer to a char :D
<andrewrk> is there a way to fix it by changing the definition of puts?
<fengb> Pointer to array would be a double pointer
<ikskuh> andrewrk: don't use "&" here
<ikskuh> arrays decay to pointers in C
<andrewrk> it's not a double pointer
<ikskuh> so doing the "&p" is "wrong"
<ikskuh> https://en.cppreference.com/w/c/io/puts => wants a pointer to "char const *" and not "char const (*)[N]"
<ikskuh> btw: why are you including inttypes.h instead of stdint.h?
<ikskuh> https://en.cppreference.com/w/c/types/integer inttypes.h defines printing macros
<andrewrk> it's not a double pointer, check the output: https://godbolt.org/z/aW79as
<ikskuh> yeah, but it's a pointer to array :D
<ikskuh> *[N]u8 instead of [*]u8
<ikskuh> that's why the pointer types are incompatible
<andrewrk> inttypes was just a typo
<ikskuh> :D
<andrewrk> *[N]u8 is correct tho. so how do I make the fn sig for puts be a [*]u8 instead of *u8
<fengb> There’s no such thing in C
<ifreund> it's C, you can't barring complier extensions I'm not aware of
<ikskuh> [*]u8 and *u8 are the same in C
<fengb> u8 is identical to []u8
<ikskuh> so the fnsig is correct
<andrewrk> this is dumb
<ifreund> yes
<ikskuh> yes
<fengb> Well it’s C. This is why you made Zig
<andrewrk> I hadn't hit this particular thing yet, or at least I don't remember it
<ifreund> this is also why you'd have a #define MAIN_ANON_0_LENGTH 13
<ifreund> and use that everywhere because you can't get the length from the variable
<ikskuh> also, puts *needs* char, not uint8_t
<ikskuh> char is neither uint8_t nor int8_t
<leah2> it is, but you dont know which...
<andrewrk> this will be solved by C backend emitting #includes instead of function signatures for extern "c" functions
<leah2> (on a posix system)
<ikskuh> leah2: NO. it's not "one of both", but "neither"
<ikskuh> uint8_t is "unsigned char", int8_t is "signed char"
<leah2> but the warning says
<ikskuh> char has a "unspecified" signedness
<ikskuh> btw, andrewrk: https://godbolt.org/z/b4brh4
<leah2> parameter of type 'const uint8_t *' (aka 'const unsigned char *')
<ikskuh> you can see that passing "array" is correct here
<ifreund> ah so you're not allowed to know if it's signed or not?
<leah2> so on this machine its unsigned chars
<ikskuh> ifreund: correct :D
<leah2> ah wait, this is just uint8_t. my bad
<ikskuh> leah2: that array is using "uint8_t", not "char" ;)
<leah2> yes
<ikskuh> "char" is wild
<ifreund> ugh, does this mean that zig needs a c_char type?
<ikskuh> actually, yes :D
<ikskuh> you can define the signedness as a compiler param though
<andrewrk> ikskuh, this is helpful, thanks
<ifreund> it's at least guarenteed to be 8bits though right?
<ikskuh> C char is horrible
<ikskuh> andrewrk: _Generic can be used to debug a lot of stuff
<leah2> ikskuh: in C, at least 8 bits. in POSIX, exactly 8 bits
<ikskuh> btw, another neat trick (which works in C++) is referencing non-implemented templates :D
<ikskuh> ifreund: only guarantee for char is sizeof(char)==1
<ikskuh> oh, and while we're at it:
FireFox317 has quit [Ping timeout: 264 seconds]
<ikskuh> sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long int) <= sizeof(long long int)
<ifreund> so char can be 64 bits?
<ifreund> cause long long int is required to be at least 64 iirc
<ikskuh> ifreund: give me a second
<ifreund> ok so if I understand correctly c_char is only needed when exporting C abi functions right?
cole-h has quit [Quit: Goodbye]
<andrewrk> right
<ikskuh> btw, andrewrk: for the c backend, you might want to read §5.2.4.1 of the C99 standard
<ikskuh> 5.2.4.1 Translation limits
<andrewrk> thanks
cole-h has joined #zig
<ikskuh> which defines how extreme your translated code can get
<ikskuh> quote: > — 127 nesting levels of blocks
ur5us has joined #zig
<ikskuh> ifreund: long has no defined size i think
<andrewrk> ugh rendering types is a nightmare
<ikskuh> yes.
wootehfoot has quit [Quit: Leaving]
<ifreund> ikskuh: I was just going off of https://en.wikipedia.org/wiki/C_data_types
<Cadey> does zig target the original gameboy?
<andrewrk> not yet
<pjz> ifreund: you said "the std.mem.Allocator interface doesn't work at comptime" ... but I don't see that I'm trying to make it do so. It's not marked comptime.
cole-h has quit [Ping timeout: 260 seconds]
a92 has joined #zig
notzmv has joined #zig
SimonNa has quit [Remote host closed the connection]
notzmv has quit [Ping timeout: 240 seconds]
notzmv has joined #zig
<pixelherodev> andrewrk: I missed something; why does CBE need to use #includes instead of fnsigs for extern "c" fns?
a92 has quit [Quit: My presence will now cease]
leon-p has quit [Quit: leaving]
<andrewrk> pixelherodev, never mind that. but check the branch I just merged into master, as well as https://github.com/ziglang/zig/issues/7589
<andrewrk> I added the new type of test that lets you run the C code that you emitted, and got hello world working. your cbe code doesn't handle update() correctly tho
<pixelherodev> Nice!
<pixelherodev> Less nic!
<pixelherodev> Hey wait... you said CBE was supposed to be separate from incremental compilation, so updates shouldn't occur?
<pixelherodev> (so was never tested)
wilsonk has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
neptunepink has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
spiderstew_ has joined #zig
neptunepink has joined #zig
spiderstew has quit [Ping timeout: 268 seconds]
neptunepink has quit [Ping timeout: 272 seconds]
neptunepink has joined #zig
neptunepink has quit [Ping timeout: 240 seconds]
neptunepink has joined #zig
neptunepink has quit [Ping timeout: 246 seconds]
neptunepink has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<pixelherodev> andrewrk: wait, so do we want to go back on the earlier decision then? We want CBE to be incremental now? :(
<andrewrk> my stance has always been the same on this, all the backends support the same API. the extent to which they take advantage of it is flexible
ur5us has quit [Ping timeout: 264 seconds]
<pixelherodev> we explicitly decided that CBE would not support incremental compilation, since there was no use case for it - which is why update was marked unreachable
<pixelherodev> we could just have it @panic instead of unreachableing, to make it explicit that it's not supported? ("C backend does not support incremental compilation!" for instance)
<andrewrk> the frontend, which supports incremental compilation, gets to have the same API for every backend
<pixelherodev> Wait, hold on - which function is update? We use updateDecl, don't we?
* pixelherodev pops open source
<andrewrk> I think you are overestimating the changes required to conform to the API
<pixelherodev> Yeah no, I see
<pixelherodev> Compilation.update, right?
<pixelherodev> Okay, I was thinking in terms of the pre-Compilation API
<pixelherodev> I'll tackle that issue within the next ten hours or so, depending on when I end up sleeping
<pixelherodev> Thanks for the clarification :)
<andrewrk> I think if CBE wants to be maximally simple, you would just ignore updateDecl(), ignore deleteDecl(), and do everything inside flush()
<andrewrk> right now it's doing deleteDecl() => unreachable
<pixelherodev> Right...
<pixelherodev> Okay, so is the idea to change Compilation.update to invoke CBE differently, so we don't updateDecl, or to support incremental?
<andrewrk> no changes to Compilation.zig, it's already calling the backend API correctly
<pixelherodev> Gotcha,
<pixelherodev> Ahh okay, I see
<pixelherodev> ... need to pull a new static Zig :P
<pixelherodev> my stage1 build is too out of date to build stage2 lol
<pixelherodev> Okay, good to go :)
<pixelherodev> Sheesh this is not going to be pleasant... codegen now takes long enough to be visible! :(
<pixelherodev> Whelp, on the bridge side, this just inspired me to redo swathes of the zyg design :P
<pixelherodev> Uh... master fails on test-stage2 after wiping the cache...
<pixelherodev> This'll be fun. Global cache, maybe?
<pixelherodev> With the latest static zig installed, I'm unable to build an unmodified stage2 from master after nuking all caches :( I get an index out of bounds finding the zig path in the test runner? Weird...
<pixelherodev> There breaking changes since the last nightly?
* pixelherodev sighs
<pixelherodev> 7ca9f3bc7ba1a413ea7f8b88dfafba3d0f842f6e breaks test running for me, but looking at the code, I don't see *why*
<andrewrk> you always need to rebuild zig after pulling master
<pixelherodev> Ohhhh, I see what happened, yeah
<pixelherodev> andrewrk: do you happen to have a static build you can upload somewhere? :P Library is fine, but my stage1 binary doesn't pass its own path to the test runner
<pixelherodev> Otherwise, I'm going to just have to wait for the next nightly :P
<pixelherodev> or, more likely, send an untested PR :P
<pixelherodev> andrewrk: is it fine to just call `codegenDecl` for everything in the decl_table on flush() ?
<pixelherodev> Or should it be starting with exports and then dependencies?
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
ur5us has joined #zig
wilsonk_ has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
lucid_0x80 has joined #zig
FireFox317 has joined #zig
<ikskuh> <ifreund> ikskuh: I was just going off of https://en.wikipedia.org/wiki/C_data_types
<ikskuh> yeah, i was going after the C99 standard
<ikskuh> there is a limits.h description where it explicitly says "the implementation should exchange the limits diplayed with the actual values"
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
podge has joined #zig
FireFox317 has quit [Quit: Leaving]
l1x has quit [Quit: Connection closed for inactivity]
tane has joined #zig
koakuma has joined #zig
<koakuma> So, forgive me for being rude but
<koakuma> Is there any plans for multithreaded compilation?
<koakuma> I find that (at least, stage0/1) builds are still single-threaded
<ikskuh> koakuma: yeah, there is
<ikskuh> problem with building zig itself is that the linking takes like 95% of the time :D
<ikskuh> and this is single-threaded
<ikskuh> the stage1 compiler actually builds C projects multithreaded already
<ikskuh> and this will continue with zig sources as well in the future ):
<ikskuh> * :)
<koakuma> Oh, that's nice
<koakuma> Here the linking is fast, it's zig1.o that takes a long time to build
<koakuma> Spending some 25 mins everytime I have to rebuild stage1 is something I don't particularly like :p
<ikskuh> i think that's the linking part tho, it just shows zig1.o :D
<koakuma> Ahh so it's linking
l1x has joined #zig
midgard_ is now known as midgard
alexpana has joined #zig
alexpana has quit [Client Quit]
alexpana has joined #zig
<koakuma> Ah yeah, I just remembered that I hit this weird f128 printing bug on sparc64
<koakuma> std.debug.print("{} {}\n", .{num, @floatCast(f64, num)}); prints different values
<koakuma> Even though the formatter will call std.fmt.formatFloatScientific which will cast its parameter into f64 anyway
<koakuma> But if the code is cross-compiled on an x64 host then everything's okay
<koakuma> Are there some comptime magic I missed here?
cren has joined #zig
WilhelmVonWeiner has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 264 seconds]
save-lisp-or-die has joined #zig
waleee-cl has joined #zig
riba has joined #zig
donniewest has joined #zig
carsme has joined #zig
carsme has quit [Client Quit]
notzmv has quit [Read error: No route to host]
notzmv has joined #zig
FireFox317 has joined #zig
radgeRayden has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
koakuma has quit [Quit: Leaving.]
wootehfoot has joined #zig
leon-p has joined #zig
podge has quit [Remote host closed the connection]
cole-h has joined #zig
<andrewrk> it's not linking that takes 95% of the time, it's building zig1.o
<andrewrk> 25 mins sounds like a release build on oldish hardware. do you perhaps intend to be doing a debug build?
SimonNa has joined #zig
<ikskuh> andrewrk: wow, why does it take *that* long?
<ifreund> stage1 is slow and llvm is slow
<andrewrk> ikskuh, slap on a -ftime-report and you'll have a detailed answer
jjido has joined #zig
<ikskuh> i wonder if i built wrong all the time, i'm using cmake :D
<g-w1> if you have ~8 gb of ram and no swapping it will probably take a while.
ehaas has joined #zig
ehaas has quit [Client Quit]
ehaas has joined #zig
dumenci has quit [Ping timeout: 256 seconds]
frett27 has joined #zig
bitmapper has quit [Quit: Connection closed for inactivity]
kbd has joined #zig
<kbd> Hi there. Just started learning Zig a few days ago. As a first exercise, I'm rewriting my shell prompt in Zig so that it's portable to non-posix shells in case I want to use Nu or Xonsh etc. Been poring over the stdlib for a while trying to find where "atoi" is and I haven't been able to find how to convert a string to an int so I figured I'd just
<kbd> hop on IRC and ask.
wilsonk_ has quit [Ping timeout: 240 seconds]
<ifreund> kbd: std.fmt.parseInt()
nycex has quit [Quit: Quit]
nycex has joined #zig
<kbd> ty ifreund!
<kbd> didn't expect that to be in 'fmt'
<ifreund> it does feel a little weird for it to be there but I don't know of anywhere else it would make more sense
bitmapper has joined #zig
ur5us has joined #zig
hnOsmium0001 has joined #zig
kbd has quit [Remote host closed the connection]
cren has quit [Quit: cren]
wilsonk_ has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
<alexpana> is that pascal? :D
<pixelherodev> andrewrk: is it fine to just call `codegenDecl` for everything in the decl_table on flush(), or should I start at exports and recursively check dependencies? With most backends, the usage of updateDecl allows for not thinking about it, since they're added to a work queue; we don't have that, which means all of the logic of "what needs to be done" needs to be replaced with "for decl in all_decls". I'm
<pixelherodev> just not certain what `all_decls` is in this case...
<andrewrk> it's fine to iterate the decl_table on flush()
<pixelherodev> I wasn't sure, thanks for clarifying!
<andrewrk> I'm gonna live stream some stage2 development in 20 min. https://www.twitch.tv/andrewrok
<pixelherodev> Anything in particular?
<pixelherodev> Might be good to catch up on the changes in internals since I last looked; Compilation.update should not have caught me by surprise! :(
<FireFox317> andrewrk, ah nice!
<ifreund> pixelherodev: comptime function calls is listed as the agenda
<pixelherodev> Ah, neat!
* pixelherodev spies
wootehfoot has quit [Quit: Leaving]
GrooveStomp has quit [Read error: Connection reset by peer]
strmpnk has quit []
cararemixed has joined #zig
tane has quit [Quit: Leaving]
<pixelherodev> andrewrk: question for some point after the screen (hence here and not irc.twitch): why does sema operate on IR and not AST? Is it faster? Easier?
<ifreund> pixelherodev: afaik it is because IR is typed
<g-w1> no, sema turns zir into typed ir. my guess is less code in zir_sema.zig and a little more in astgen (for example, catch and orelse are simmilar, if for and while simmilar)
<pixelherodev> hmm
<FireFox317> isnt that for comptime?
<FireFox317> pixelherodev, see top comment in zir_sema.zig
<pixelherodev> FireFox317: yes, but *why* is there untyped IR?
<pixelherodev> I'm confused why sema doesn't operate on the AST, and astgen doesn't just produce typed IR
<pixelherodev> (instead of using two IRs...)
<FireFox317> yeah okay, i dunno actually