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/
dermetfan has quit [Ping timeout: 244 seconds]
<yeti> zig-bootstrap on a pi1 probably will need 2 weeks or more?
<yeti> I even tried on cubietrucks.... failed... generated some code that didnt match the CPU
<leeward> It'll fail when it runs out of RAM.
<leeward> That's my experience on RPi, anyway.
<yeti> nono... it complained about instructions not matching the cpu flavour
<shakesoda> yeah i'm not brave enough to bootstrap it for the pi on the pi, but the bins on the site work.
<leeward> Well, I tried on a Pi 1B, and after I turned off oomkiller it stopped taking out my ssh session and just failed.
<shakesoda> building is really a lot slower than i feel it should be (multiple times slower than a c compiler) but it does work
<leeward> It only took about a day though.
<yeti> seems to have some problems on A20
<shakesoda> the initial build where it builds cache for c stuff is particularly awful
<shakesoda> that oom'd my pi zero, i had to increase swap size
<leeward> Oh, I suppose I could have added swap...hmm, maybe next time.
<yeti> :-P
<leeward> That sounds even slower though.
<shakesoda> on the pi 4 i haven't meaningfully had problems, it's just very sluggish
<shakesoda> the thing has egregious resources though, versus what should be needed (fancy new 8gb model)
<leeward> holy crap
<leeward> I like how cheap "embedded" low-power computers these days are way more performant than the $2k machine I built to take to college.
* yeti installed netbsd on pi1 last night
<shakesoda> yeah, it's not actually that much worse than my laptop is
<shakesoda> the i/o is slower and the gpu is a bit weaker.
<leeward> Hmm, actually I think that was $1k
<leeward> but it was 20 years ago so...inflation
<shakesoda> single thread performance is worse, too, but not by so much that it's a primary concern
<shakesoda> i moved from the sd card to a tiny old 32gb ssd over usb3, and that certainly helped
gruebite has quit [Quit: WeeChat 2.8]
<pixelherodev> Part of the problem is cross-platform support though
<pixelherodev> If you built a Zig compiler which could only target the Pi, the build would be cut down by an order of magnitude, easily
<pixelherodev> Since LLVM has like 20 backends, it'd get rid of a large chunk of code
<pixelherodev> If you could tweak it further to only support a specific *model*, it'd be even smaller
<pixelherodev> For good or ill, that's not possible
<pixelherodev> Old hardware had dedicated compilers
<shakesoda> to be sure, the zig builds are massively slower than, say, gcc is.
blinghound has quit [Ping timeout: 245 seconds]
frmdstryr has quit [Ping timeout: 256 seconds]
keegans has joined #zig
<keegans> really confused at what's going on here: https://github.com/ziglang/zig/blob/master/src/stage2.cpp#L274 is `libc.txt` no longer supported? (been a while since I've used it with Zig)
<keegans> can't find references to the keys in the source either
<keegans> ok nvm- got it. it's @ src-self-hosted/libc_installation.zig
frmdstryr has joined #zig
craigo has quit [Ping timeout: 244 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
doesntgolf has quit [*.net *.split]
st4ll1 has quit [*.net *.split]
Cadey has quit [*.net *.split]
eddyb[legacy] has quit [*.net *.split]
dongcarl has quit [*.net *.split]
traviss has quit [*.net *.split]
corvid has quit [*.net *.split]
_whitelogger has joined #zig
HesamR has joined #zig
HesamR has quit [Quit: Connection closed]
WilhelmVonWeiner has quit [Read error: Connection reset by peer]
bgiannan has quit [Read error: Connection reset by peer]
marnix has quit [Ping timeout: 260 seconds]
Ashpool has joined #zig
traviss has quit [Remote host closed the connection]
dermetfan has joined #zig
_whitelogger has joined #zig
dddddd has joined #zig
waleee-cl has joined #zig
FireFox317 has joined #zig
xackus_ has joined #zig
craigo has joined #zig
marnix has quit [Read error: Connection reset by peer]
Ashpool_ has joined #zig
Ashpool has quit [Ping timeout: 246 seconds]
marnix has joined #zig
xackus_ has quit [Ping timeout: 260 seconds]
marnix has quit [Ping timeout: 265 seconds]
marnix has joined #zig
Ashpool_ has quit [Remote host closed the connection]
FireFox317 has quit [Ping timeout: 256 seconds]
<ikskuh> hm
<ikskuh> how can i write a file to an arbitrary directory from build.zig?
<ikskuh> using addWriteFile doesn't look like it's build for this job
mikdusan has joined #zig
tsujp has joined #zig
doesntgolf has joined #zig
tsujp has quit [Quit: WeeChat 2.9]
tsujp has joined #zig
<ifreund> ikskuh: inside the install prefix?
<ifreund> installFile() takes a relative path
<ikskuh> no, in the build directories
<ikskuh> so relative to build.zig
<ifreund> I suppose you just use std.fs then no?
<ikskuh> yeah, but it's not a build step then :(
<ikskuh> well, enough for now
KoljaKube has joined #zig
tsujp has quit [Quit: WeeChat 2.9]
tsujp has joined #zig
FireFox317 has joined #zig
<ikskuh> damn you zig and your undefined behaviour sanitizer in C :D
waleee-cl has quit [Quit: Connection closed for inactivity]
<tsujp> if I have a file `c.zig` which is nothing but c imports via `usingnamespace @cImport` how do I import those imports into another zig file and use them?
<ifreund> tsujp: you need to do `pub usingnamespace ... `
<tsujp> and sorry I have, then it's just `@import("path/to/file.zig");`?
<ifreund> and then you can `const c = @import("c.zig"); c.foo();`
<ifreund> paths for imports are relative
<tsujp> gotcha
<ifreund> also if you didn't realize yet, files in zig are structs
<tsujp> good to know, still getting the hang of zig just found it a few days ago
<tsujp> I'm curious, I'm going through the source code for that exmaple game oxid (here: https://github.com/dbandstra/oxid) and I can see the use of `zig-hunk` which is inspired from Quake's hunk
<tsujp> Why did they need a stack allocated memory management library when you can use the Heap?
<tsujp> Or is it that this is being alloocated on the heap (surely it is...?) and that this library gives you a "stack-like" data structure to use
marnix has quit [Ping timeout: 256 seconds]
bastienleonard has joined #zig
KoljaKube has quit [Ping timeout: 272 seconds]
<ifreund> tsujp: not sure, probably something to do with wasm which seems to be the target for that
<tsujp> I did some digging and apparently the hunk is a datastructure the quake engine used to keep heap memory allocated to it contiguous by allocating high and moving "inwards" as required
<tsujp> ifreund: say there is a set of items { 1, 2, 3, 4, 5, 6 } the slice syntax `[1..]` means "index 1 until the end" right?
<ifreund> sounds like a performance thing then
<ifreund> tsujp: yep
KoljaKube has joined #zig
frmdstryr has quit [Ping timeout: 260 seconds]
Sahnvour has quit [Quit: WeeChat 2.8]
riba has joined #zig
marnix has joined #zig
Akuli has joined #zig
<KoljaKube> Hm, Allocator does not work with non-slice pointers?
<ikskuh> allocator.create() ;)
<keegans> this functionality requires allocation, is that available in the compiler_rt at this time?
Sahnvour has joined #zig
<FireFox317> keegans, hmm good question, im not sure actually
<keegans> yeah, it's somewhat problematic since we need a GPA to expand TLS on demand
<keegans> we could hypothetically allocate a big ELF section and cap it, but that is suboptimal
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<KoljaKube> ikskuh: But that does not support reallocation, right?
<ikskuh> no, as it's illogical to reallocate a single object ;)
<ikskuh> single objects don't change size
<KoljaKube> Ah, OK, didn't try it out but I intended to `create` a [N]u8, where reallocation would make sense (even if not strictly speaking)
<ikskuh> err
<ikskuh> that's just allocator.alloc(u8, N)
<ikskuh> so allocate a slice of u8 instead of a fixed-size array
<ikskuh> [N]u8 will always be N elements large
<ikskuh> if you allocate multiple of them, you get another [N]u8
<ikskuh> if you allocate a []u8, you get a dynamic sized type (slice)
<KoljaKube> I'm trying to wrap a C library where the only memory allocation function that I can pass in is a realloc(c_void*, usize)
<fengb> That’s not possible with naive Zig allocators
<fengb> I’m actually working on a compat layer that can enable C style allocations
<ikskuh> realloc() is fully capable and you can route a global allocator into those
<ikskuh> so you have a realloc() function that accesses a global allocator
<fengb> But most Zig allocators cannot take a pointer and reconstitute its size
<ikskuh> realloc(NULL, size) is "alloc", realloc(ptr, size) is "realloc", alloc(ptr, 0)" is free
<KoljaKube> I also have a pointer to an allocator instance in that call, I don't need it to be global
<ikskuh> oh, neat
<KoljaKube> I had hoped that I could somehow, inside my wrapper, bridge all the differences
<fengb> Oh we might be working on something similar
<KoljaKube> ikskuh: My PR isn't accepted upstream, but I added a c_void* userData ;-)
<KoljaKube> Is the memory layout of a slice documented somewhere?
<fengb> No it’s intentionally unspecified
ask6155 has joined #zig
<ask6155> hello!
<KoljaKube> fengb: So no hope of, say, extra-allocating two usizes extra at the start to store some more information about the following memory?
<KoljaKube> ask6155: Hi there!
<ask6155> hi!
<fengb> You can allocate @sizeOf([]T). That’d be fixed but the layout isn’t
<KoljaKube> By the way, I'm used to new/delete, but I'm assuming that reallocating stuff is usually done for complete arrays/struct/etc, not in the middle of them, right?
<fengb> I’m not actually sure why though. I’d love to put slices into packed structs :(
<KoljaKube> OK, so I can take the requested memory size, allocate a slice instead, and return the .ptr, right? And if it's time to realloc, I am passed said ptr. Can I then use some builtin to get the slice's address from that ptr?
<fengb> A slice is a glorified pointer
<KoljaKube> I thought it's a pointer + a size
<fengb> Yeah
<keegans> is there a string replacement impl in Zig std or do I roll my own?
<fengb> There’s no real way of getting the address of reversing the ptr to slice though
<KoljaKube> So that size must be stored somewhere. And if it's not a defined layout, I can't just assume "the usize before the ptr"
<KoljaKube> Ah, OK
<KoljaKube> Too bad
<fengb> Right, I don’t think you can reliably get the data
<fengb> You can create your own packed struct though
* KoljaKube slaps his head
<KoljaKube> duh
<fengb> How I’m doing it is putting the size exactly 16 bytes before the pointer I return to the user
<KoljaKube> So I guess I can rely on every pointer passed to realloc being something I initially returned from some allocation function, right?
<fengb> That’s the expectation placed on the dev yes
<KoljaKube> On the dev calling or implementing realloc?
<fengb> Calling
<fengb> We usually insert some asserts for sanity
<KoljaKube> OK, good
<fengb> Usually = sometimes
<ikskuh> more asserts for all!
<KoljaKube> How would I assert that without keeping a list?
<fengb> Depends on metadata layout
<KoljaKube> OK
<fengb> My more complicated allocator has specific numbers in memory locations that it can be
<fengb> So it’s semi trivial to do an extra check to make sure those are sane
<KoljaKube> So it's 100% sure, but close enough?
<fengb> Yeah there’s a pointer which needs to be aligned, and a size which can only be a power of 2
<fengb> So it’s a useful sanity check, but can’t be completely relied upon
<fengb> The debug allocator would eventually check for a lot of these cases
<KoljaKube> OK, I think I'm getting somewhere. Thanks, you helped a lot!
<fengb> np
<ask6155> If I have a C struct which can have a field as null, can I set it as an undefined and get away with it?
<KoljaKube> undefined should be uninitialized as far as I understand
riba has quit [Remote host closed the connection]
<fengb> Yeah, it’s set to 0xaaaa in safe modes for debugging but it’s “probably” uninitialized otherwise
<KoljaKube> Depends on what exactly you are doing, but I have been using a lot of std.mem.zeroes for large C structs lately
<tsujp> zig docs state `Use undefined to leave variables uninitialized` for `master`
<KoljaKube> (zero the whole struct, set what you want)
<ask6155> It says missing field
<KoljaKube> Not very zig-like, but initializing structs with dozens of fields at define-time is not practical
<fengb> You need to assign something to the field. Undefined is fine if you’ll overwrite it later before using it
<KoljaKube> Yeah, you can't just leave it out
<fengb> There’s also mem.zeroInit, where it’ll zero out any field that wasn’t specified
FireFox317 has quit [Quit: Leaving]
<ask6155> The field is a const char* but it can be NULL which means the library will detect it or something
<KoljaKube> You bring up a good point, I had a similar problem earlier. To return NULL to C, I had to `return @intToPtr(*allowzero c_void, 0)` - that can't be the best way
<ask6155> How do I convert 0x0001 to a []const u8?
<fengb> Change the ptr definition to `?*c_void` and you can assign null
<ask6155> what
<fengb> That was meant for KoljaKube
<ask6155> oh
<KoljaKube> Heh, all those permutations of casts and return values, and I must have missed that one. Seems obvious, thought I checked that
<fengb> ask6155: do you want a one element slice? “\x01” is the easiest as a constant
<fengb> `[_]u8{0x01}` will build an array and you can slice that
<ask6155> yeah I wanted a one element slice
<tsujp> Is there a way to specify style with zig similar to how you can with clang (I think it is?)
<KoljaKube> Arbitrary u16s should be castable to fixed-sized arrays before slicing, if I'm not mistaken
<KoljaKube> tsujp: Are you talking about zig fmt?
<tsujp> KoljaKube: I think so? I am using the sublime text Zig pacakage and it's changing the whitespace in my code etc
<KoljaKube> There are no options there I think
<KoljaKube> Yeah, that would be fmt
<fengb> You can disable formatting but there’s no config for the formatter
<ask6155> where is the documentation for "\x01" syntax?
<KoljaKube> If you end lists with trailing commas, the lists will be multiline, without they will be fit in one line if possible, if that helps
<tsujp> ask6155: https://ziglang.org/documentation/master/#Primitive-Values under "Escape sequences"
<tsujp> ask6155: specifically: `\xNN hexadecimal 8-bit character code (2 digits)`
<tsujp> Is there an API for `fmt` at the moment? I could work on a PR to add options to it for instance
<KoljaKube> I've really grown to like no-option formatters. I may not like the result, but at least there won't be a discussion about it :D
<fengb> Intentionally no options
<tsujp> Fair enough
<Akuli> "it's a feature, not a bug" :D
<tsujp> I guess I shall try and stick with it hohoh
<KoljaKube> But if it would use tabs instead of spaces I couldn't use it ;-)
<tsujp> Eww tabs gross
<tsujp> Tabs aren't even allowed in source files are they
<KoljaKube> Nope
<Akuli> here we go again lol
<tsujp> Take that tab vs spaces people
<fengb> To quote Go fmt: it’s nobody’s friend. Therefore it’s everybody’s friend
<tsujp> Actually the only reason I was curious about `fmt` is because I see in the docs the return of structs formatted as `return StructName {` whereas `fmt` is formatting my struct return as `return StructName{` (no space between StructName and {)
marnix has quit [Ping timeout: 246 seconds]
<tsujp> Very, very, very, very trivial that single space but I was just curious
<fengb> Hmm yeah I noticed that too. I dunno if there’s been discussion
<fengb> fmt is open to change. We just don’t want configuration options :P
<tsujp> I'll subscribe to that
marnix has joined #zig
dermetfan has quit [Ping timeout: 272 seconds]
<ask6155> ok I passed an optional i32 which is set as NULL to my C function. There was no compile error but when I ran the program it said attempt to use null value. But that was the POINT!
marnix has quit [Ping timeout: 264 seconds]
<KoljaKube> C doesn't know optional values
<ask6155> so how do I pass a pointer to null?
<KoljaKube> Oh, I misread, you weren't passing a value
<KoljaKube> I think you should be able to pass null optionals as null ptrs. What's the function parameter type and the type of the variable exactly?
<ask6155> struct notcurses* notcurses_init(const notcurses_options* opts, FILE* fp);
<ask6155> "notcurses_init prepares the terminal for cursor-addressable (multiline) mode. The FILE provided as fp must be writable and attached to a terminal, or NULL. If it is NULL, /dev/tty will be opened. "
<KoljaKube> And you are passing null for fp?
<tsujp> What is u29?
<tsujp> ..29-bit integer?
<KoljaKube> 29 bit unsigned integer
<KoljaKube> maximum size of an alignment paramtere
<tsujp> why would 29 bit unsigned integer exist?
<tsujp> ah
<ask6155> I don't know how to pass NULL, I made an optional pointer to i32 and dereferenced it.
<KoljaKube> Zig has arbitrary bit size integers
<KoljaKube> Well, dereferencing an optional that is null should be an error
<tsujp> what does this part of the docs concerning alignment mean?
<fengb> Alignment must be u29 because it prevents accidentally passing in something else
<tsujp> "less than 1 << 29."
<ask6155> ok so how do I pass a NULL to a C function?
<tsujp> I mean what does the double << operator here mean, bit shift?
<fengb> Yeah
<KoljaKube> I would think you should be able to pass `null`, but I don't have an example in front of me
<tsujp> so 1 << 29 as in 1 bitshift 29 places to the left?
<fengb> Yep
<KoljaKube> As in 2^29
<tsujp> I see
<ask6155> wow I'm dumb I never thought it would just work
<ask6155> (I passed null directly)
<KoljaKube> By the way, you don't need i32, you can use c.FILE or ?c.FILE directly
marnix has joined #zig
<KoljaKube> (assuming your cImport is named `c`)
<leeward> It just occurred to me that my C wrapper tutorial doesn't mention `extern "c"` at all.
<zigusr> on windows 64 bit, does build-lib -dynamic create a 64 bit windll ?
<ask6155> wait you have a C wrapper tutorial?
<zigusr> nm, works
<tsujp> right so with alignment if you had a 3-byte sized data type, you'd have that aligned to mod 3 increments
<ask6155> oof that means I still would have to do some wrapping to get stuff done.
<leeward> ask6155: Most C libraries I've used in Zig can be used wrapper-free, but I find writing Zig wrappers around the parts I use to make it easier to write clean code.
<ask6155> yeah but I still have to do good error handling which I guess is a good thing :)
<leeward> yep
<leeward> Converting a return code + ERRNO to a Zig error makes life really nice, and it's easy.
<zigusr> where can I see examples for stdlib usage?
<leeward> zigusr: Can you be more specific? The vast majority of Zig code uses the standard library.
<zigusr> yeah, I'm coding my first line in zig, and I want to push / pull a struct from an TailQueue
<zigusr> so duckduckgo TailQueue examples doesn't help me :)
<tsujp> is using `.ptr` safe? the docs have me a tad bit confused, if I'm reading this correctly `.ptr` on an array gives the runtime-only-known pointer length
<tsujp> is this effectively the size of the array?
<tsujp> size as in size in memory not elements?
<leeward> zigusr: zig/lib/std/linked_list.zig has a test called "TailQueue concatenation"
<leeward> also "basic TailQueue test" on line 375
cren has joined #zig
<leeward> tsujp: I believe you misread the docs. .ptr gives a pointer to the array. So an [23]u8 would become [*]u8
<leeward> The address of the first element, that is.
<tsujp> Ah
<tsujp> and where is the meaning of `_` defined in the docs?
<leeward> Actually, I only see it mentioned for slices.
<tsujp> I keep seeing `_` all over the place but a CTRL+F gives 1,471 results :'(
<leeward> tsujp: I'm not sure, but it means "ignore this value." It's an error to implicitly ignore a function's return value.
<leeward> tsujp: This might help: https://ziglearn.org/chapter-1/#assignment
<tsujp> Ohhh a learn website!
<tsujp> My reading of the docs to learn shall be postponed by this instead
<tsujp> Thank you leeward
<ask6155> wait ziglearn.org?
<tsujp> Yeah TIL too
<tsujp> I even googled learning zig the other day and got nothing, so either I am extremely unlucky, suck at googling.. or both
<zigusr> is there ETA for 1.0 ?
<leeward> It's pretty new. I don't think it's got the search engines tuned for it yet.
<tsujp> soon(tm)? (I don't know hoho)
<zigusr> duckduckgo almost has nothing on zig
<ask6155> I got first hit as ziglearn.org
<ask6155> I use bing (That explains it)
<tsujp> last result on first page of google for "learn zig" search for me
<cren> I wish I had known about ziglearn.org a few months ago >_<
<zigusr> what is a good written library in idomatic zig ?
<tsujp> that would be zig standard lib no?
<leeward> cren: It was first created June 19th.
<zigusr> something pratical :)
<ikskuh> zigusr: wdym? stdlib is the biggest, most practical lib out there :D
<tsujp> hang on if you can do `_ = 10;` what is the point of that?
<cren> leeward: ah, thanks for telling me, I feel less bad now
<cren> there are example programs in the std library which I find immensely helpful
<leeward> tsujp: There isn't a point to `_ = 10;`
<leeward> tsujp: But, say you don't care about printf's return value. You can do `_ = c.printf(...);`
<tsujp> oh wait hang on, say I had a function that returned `u29` for example, and I wanted the function to run but as you say I didn't care about what it returned at all I'd then use `_` right? `_ = runThatu29FunctionPlease()`?
<leeward> tsujp: Exactly.
<tsujp> And this keeps the typing of functions but allows them to effectively work as `void` (from C) if I so desire
<leeward> It says "this function is being run for its side effects" to anyone reading the code, which should raise alarms.
<leeward> yep
<leeward> The only value you can ignore is `{}` which is the void value.
<fengb> And noreturn 🙃
cren has quit [Remote host closed the connection]
<leeward> That's not a value :P
cren has joined #zig
xackus_ has joined #zig
ask6155 has left #zig ["later!"]
<tsujp> 2.5 hours into this mix (https://www.youtube.com/watch?v=h7BTVFOAwkQ) learning zig but it's 12:30 am now and if I want to get up on time I have to go to bed :'(
<tsujp> more zig tomorrow hohoh
<tsujp> thank you for the help :)
<leeward> Also: I've seen C code "int foo(whatever) __attribute__((noreturn));"
<leeward> Time zones are fun.
<leeward> It's 12:30 PM here.
<tsujp> So you could be in anything from UTC-3 to UTC-5 because daylight savings make it even more fun
Ashpool has joined #zig
<fengb> Well actually offsets are fixed. You shift offsets when switching daylight savings
<tsujp> i have purged all daylight savings knowledge from my head except that they exist, in Western Australia there is none hoho
<tsujp> UTC+8 always
<fengb> Australia is the most confusing thing ever. Half hour zones and half the country observes DST
<leeward> Doesn't India have half hour time zones too?
cren has quit [Remote host closed the connection]
<leeward> I want my state to move to atlantic standard year-round. EST is crap.
<ikskuh> andrewrk: is there a way to access the c type __builtin_va_list ?
Sahnvour has quit [Quit: WeeChat 2.9]
cren has joined #zig
<ikskuh> hm
<keegans> how can I run 1 specific test/file in Zig std? currently using `zig build test-std`~ but that does everything
<keegans> ya i'm just an idiot lel
marnix has quit [Ping timeout: 240 seconds]
frett27 has joined #zig
<cren> can main() return something other than void?
<leeward> sure
<cren> what happens if it does? does it go to stdout?
<leeward> Same thing that happens in C
<cren> what happens in C?
<leeward> Oh, apparently I'm wrong.
<leeward> Ok, so functions can return void, !void, noreturn, u8, or !u8.
<leeward> If it's one of the u8s, it passes the return code up to the OS.
<fengb> Returning anything becomes a status code
<fengb> Nonzero is considered failed execution
<leeward> If you run pretty much any program on a *nix-like system from a shell like bash, the return code will get stored in `$?`.
<cren> yeah
<cren> what about noreturn? how is that different from void?
<leeward> noreturn functions don't halt.
<fengb> noreturn is a special type that means the function never returns
<cren> what's the use case for that?
<fengb> e.g. triggers a trap
<leeward> Oh, and if Zig's main returns an error, the return code is 1.
<fengb> os.exit() is a noreturn
<leeward> Code running on embedded systems frequently never returns from main.
<fengb> Something like C’s longjmp would also be noreturn
<cren> ah I hadn't considered embedded
<fengb> In OSs, the _start function is noreturn as well
<fengb> You’re supposed to call exit instead of relying on a return address
Sahnvour has joined #zig
<pixelherodev> For userspace too
<pixelherodev> _start is noreturn, and calls main, handling the return type via comptime reflection
<cren> if I fn _start() can I overwrite _start? (not that I want to, I'm just curious)
cole-h has joined #zig
<pixelherodev> It's possible, yes
<pixelherodev> I'm not 100% sure what the correct method to do that is for userspace though
<leeward> callconv(.Naked)
<pixelherodev> I know
<leeward> according to that
<pixelherodev> But that doesn't stop the normal _start from being defined, does it?
<leeward> Easy to find out!
<pixelherodev> I know
<pixelherodev> I'm looking rn ;P
<pixelherodev> It works, yeah
<pixelherodev> start.zig exports start only if the root file doesn't have a start function
<leeward> hmm, didn't let override the return value from main though
<cren> I can't build a hello world with pub fn main() noreturn {...}
<cren> `expected type 'noreturn', found 'void'
<leeward> That's because you returned from main.
<leeward> You probably want void, not noreturn.
<cren> I was just experimenting
<leeward> Try putting `std.os.abort()` at the end of your main function. That'll let it be noreturn.
<cren> cool. 'zsh: abort bin/main'
<cren> appears to return with status 134
<cren> is there going to be a context management statement in zig like python's 'with'? there's 'defer' in zig and I was just wondering whether that's supposed to replace 'with'/'using' or not
<leeward> I don't think there's a plan to put context managers in the language, though they wouldn't be hard to implement in userspace.
<fengb> Not currently in the plans. There’s a parent issue about resource management though
marnix has joined #zig
<leeward> defer and errdefer do handle most cases where you'd want Python's `with`.
<fengb> Wow that’s ancient. It should link to a more up to date discussion
WilhelmVonWeiner has joined #zig
marnix has quit [Ping timeout: 240 seconds]
<cren> how can I see the type of a thing while debugging? using print with format strings just turns the type into the word "type" apparently
<fengb> @typeNam3
<fengb> @typeName
<leeward> Ordering delivery during a pandemic is not always good. 2 hours later, the order is cancelled.
<cren> a belated thank you fengb
<cren> oh
<cren> 'error: expected type 'type' found '@TypeOf(std.net.Address.parseIp).ReturnType.ErrorSet!std.net.Address'?
<cren> the thing I'm trying to print is the returned value from net.Address.parseIp
<leeward> Forget a try?
<cren> leeward: that's probably it
keegans has quit [Quit: WeeChat 2.7]
nvmd has joined #zig
marnix has joined #zig
nvmd has quit [Quit: Later nerds.]
KoljaKube has quit [Ping timeout: 246 seconds]
waleee-cl has joined #zig
marnix has quit [Ping timeout: 240 seconds]
opDispatch has quit [Quit: Konversation terminated!]
Ashpool has quit [Read error: Connection reset by peer]
Ashpool has joined #zig
marnix has joined #zig
jjido has joined #zig
cren has quit [Ping timeout: 246 seconds]
xackus_ has quit [Ping timeout: 240 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marnix has quit [Ping timeout: 260 seconds]
craigo has quit [Ping timeout: 240 seconds]
cole-h has quit [Quit: Goodbye]
frett27 has quit [Ping timeout: 240 seconds]
Akuli has quit [Quit: Leaving]
nikita` has quit [Quit: leaving]
doublex has quit [Read error: Connection reset by peer]
traviss has joined #zig
_whitelogger has joined #zig
keegans has joined #zig
Sahnvour has quit [Quit: WeeChat 2.9]
bastienleonard has quit [Ping timeout: 272 seconds]
<ronsor> Well, I have a bit of a new issue. Calling C code from zig (target: x86_64, UEFI, MSVC ABI) that attempts to use struct assignment (`struct A a, b; a = b;`) results in #06 Invalid Opcode (QEMU 2.11.1, KVM, -cpu max). This *always* happens.
<keegans> that's a really old QEMU?
<ronsor> I just used what came with my package manager. Hmm.
<ronsor> welp i'll try a newer version
<keegans> yeah like, 5.0.0 is out