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/
doublex has quit [Ping timeout: 245 seconds]
doublex has joined #zig
AlexMax has joined #zig
<AlexMax> does anybody have any experience linking against win32?
<daurnimator> a little...
<daurnimator> AlexMax: IIRC zig links against it automatically if you use functions from it
<AlexMax> i'm trying to do the "build your c program as zig" thing and I've resolved some issues, but I'm getting stuck trying to resolve WinMainCRTStartup and what looks like a bunch of standard c symbols.
<AlexMax> this is what I've got in my build system so far: https://paste.ee/p/xJQKz
<daurnimator> trying to resolv?
<AlexMax> yeah, says that (and a bunch of other standard c functions like strchr) are missing
<daurnimator> AlexMax: you shouldn't need any of that. zig includes them when you set the target as windows
<AlexMax> okay, how do I set a build target as windows?
<daurnimator> .setTheTarget
<AlexMax> Okay I need a Target for that....
<AlexMax> target looks like it's this... https://github.com/ziglang/zig/blob/master/lib/std/target.zig
<AlexMax> wait a minute, isn't the default to be Native?
<AlexMax> if I'm on widnows, and I'm compiling for windows, shouldn't that stuff be linked against automatically?
<AlexMax> (I'm compiling some C files with zig build, not compiling zig files yet)
marler8997 has joined #zig
<marler8997> wow, when did zig implement anonymous structs?!?
<fengb> It's been around since forever 🙃
<fengb> About 2 days ago
<AlexMax> daurnimator: are you sure zig links the proper stuff when dealing with win32 in C code built with zig?
<AlexMax> i'm trying to do the gradual replacement thing
<marler8997> great, is it still the plan to remove varargs? Do we know the timeline for that?
<AlexMax> strangely, it works just fine if I "zig cc", it's only zig build where I'm having issues, probably because it's turning off system libraries
dimenus has joined #zig
lunamn has quit [Quit: leaving]
protty has quit [Ping timeout: 260 seconds]
bjorob has quit [Ping timeout: 265 seconds]
marijnfs has quit [Ping timeout: 252 seconds]
<daurnimator> AlexMax: sorry I'm not sure. but zig ships at least the mingw windows headers: you shouldn't need to provide them yourself....
<daurnimator> though maybe they only get used if you target the gnu abi
<daurnimator> AlexMax: though also, I thought `zig cc` doesn't include system headers by default either...
<fengb> expected type 'main.struct:512:31', found 'main.struct:512:31'
return0e has quit [Read error: Connection reset by peer]
<fengb> Doesn't that mean they're the same type?
return0e has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
allan0 has quit [Ping timeout: 265 seconds]
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
<dimenus> can you link the instantiations?
dimenus has quit [Ping timeout: 240 seconds]
keithdc has quit [Quit: leaving]
Jezza__ has joined #zig
Ichorio_ has quit [Ping timeout: 245 seconds]
<fengb> Much smaller version: https://godbolt.org/z/uzBV2S
muffindrake has quit [Ping timeout: 276 seconds]
muffindrake has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #zig
doublex has quit [Remote host closed the connection]
doublex has joined #zig
adamkowalski has joined #zig
<adamkowalski> Do you all have any recommendations for plotting libraries I can use with Zig?
adamkowalski has quit [Ping timeout: 268 seconds]
hspak has joined #zig
halbeno has quit [Quit: Leaving.]
halbeno has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
return0e_ has joined #zig
return0e has quit [Ping timeout: 240 seconds]
mahmudov has quit [Remote host closed the connection]
ltriant_ has quit [Ping timeout: 265 seconds]
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 268 seconds]
adamkowalski has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 276 seconds]
adamkowalski has quit [Quit: Lost terminal]
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
<Snektron> I doubt there is any native library
<Snektron> I recommend gnuplot or writing a python script for matplotlib
<Snektron> Or generate latex code, tikz.datavisualizations produces some nice looking graphs
allan0 has joined #zig
<muffindrake> Is there an equivalent to zero-initialization a la {0} in C that will work with non-array structures?
<muffindrake> I see that there's a default field values for structs - am I required to specify each default initialized value?
<scientes> muffindrake, if you want an initialized value
<scientes> otherwise it is undefined
<scientes> IIUC
<muffindrake> I see. Thank you.
FireFox317 has joined #zig
return0e has joined #zig
return0__ has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
return0__ has quit [Read error: Connection reset by peer]
return0e has quit [Remote host closed the connection]
return0e has joined #zig
return0e_ has joined #zig
jmiven has quit [Quit: bye]
jmiven has joined #zig
return0__ has joined #zig
return0e_ has quit [Ping timeout: 240 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
stianhj has joined #zig
<mq32> hey
<mq32> > const stdout = &std.io.getStdOut().outStream().stream;
<mq32> this line looks like a subtle bug to me as outStream() returns a temporary value that is not stored anywhere and we take a pointer to a child element
<mq32> or is this guaranteed to work in zig?
<daurnimator> mq32: I see that pattern around a bit
<mq32> yeah, that's why i'm asking
<daurnimator> mq32: FWIW I'm fixing all of those with my incoming "Mixin" PR
<mq32> :)
<daurnimator> just waiting for a couple of other things to be merged first
<mq32> > std.io.getStdOut and related fns no longer can error
<mq32> this is a really nice addition :)
<mq32> do we have something like "float equals"?
<daurnimator> mq32: you mean like some sort of epsilon comparison?
<mq32> yeah
<mq32> i think i've seen something like that
<daurnimator> Its very rare to need it... what corner have you painted yourself into?
<mq32> "testing a conversion function"
<daurnimator> conversion to/from?
<mq32> "index on piano keyboard" to "frequency in Hz"
<mq32> 440 hertz * (2^(1/12))^(i - 49)
<mq32> it's this beauty
tines9 has quit [Remote host closed the connection]
<mq32> i haven't seen much code that is "twelfth root of 2 to the power of i minus 49"
<daurnimator> isn't ^ xor not power?
<mq32> it's notation from my calculator program :D
<mq32> 440.0 * std.math.pow(std.math.pow(2, 1 / 12), @intToFloat(note.index) - 49.0);
<mq32> this is the zig version
<daurnimator> mq32: I thought zig's std.math.pow took a type
<mq32> probably, i didn't call ths function yet :D
<mq32> it does :D
<mq32> damn lazy languages :D
return0e_ has joined #zig
<Snektron> mq32: beware,:math.pow(2, 1/12) will return 1
<mq32> probably... :D
<mq32> now you know why i want to test that :D
return0__ has quit [Ping timeout: 268 seconds]
<mq32> ha!
<mq32> my tracker is coming along :)
return0e_ has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
doublex has quit [Ping timeout: 246 seconds]
return0e has quit [*.net *.split]
slice has quit [*.net *.split]
casaca has quit [*.net *.split]
knebulae has quit [*.net *.split]
mla has quit [*.net *.split]
companion_cube has quit [*.net *.split]
SyrupThinker has quit [*.net *.split]
guan has quit [*.net *.split]
odc has quit [*.net *.split]
torque has quit [*.net *.split]
commander has quit [*.net *.split]
eddyb[legacy] has quit [*.net *.split]
casaca has joined #zig
return0e has joined #zig
knebulae has joined #zig
slice has joined #zig
odc has joined #zig
companion_cube has joined #zig
mla has joined #zig
torque has joined #zig
SyrupThinker has joined #zig
guan has joined #zig
eddyb[legacy] has joined #zig
commander has joined #zig
knebulae has quit [Remote host closed the connection]
knebulae has joined #zig
doublex has joined #zig
return0e has quit [Ping timeout: 252 seconds]
return0e has joined #zig
<muffindrake> How would I write a default initialization of a struct field that is an array, say struct { name: [_]u8 }
<muffindrake> I'm running into compile errors trying to figure that out.
<mq32> struct { name: [16]u8 = "Hello" ++ [_]u8{0}**11, };
<mq32> "name: [_]u8" is invalid as the size isn't known
<muffindrake> That seems strangely roundabout, but thanks!
<mq32> it just follows the language rules :D
bjorob has joined #zig
bjorob has quit [Ping timeout: 240 seconds]
dimenus has joined #zig
<muffindrake> Alright, and to recap, if I have a `const s = struct { name: [16]u8 = [_]u8{0} ** 16}` and wanted to make an array of this structure in a field of another, I would use `const b = struct { a: [666]s = [_]s{s{}}} ** 666`, or am I doing something horribly wrong here?
<muffindrake> Missing } at the end, anyhow.
<mq32> sounds reasonable
frmdstryr has joined #zig
<muffindrake> I was going to say that default initalization was easier to do in C, but then I remembered that there is no such thing as writing your own default initializer for structs, because no such thing exists in C.
<muffindrake> Still, it's far more convenient to write something like `uint_least16_t a[16] = {0}` than the above.
knebulae has quit [Quit: Leaving]
frmdstryr has quit [Ping timeout: 268 seconds]
return0__ has joined #zig
return0e has quit [Ping timeout: 245 seconds]
<muffindrake> Huh, I seem to have placed a variable at global scope which triggered a runtime crash, which went away when I put it into local scope into main. I'll try to get a minimal example.
<muffindrake> Is this supposed to segfault at runtime?
<muffindrake> Placing 'var c' inside main won't segfault
<FireFox317> muffindrake, if you just want to zero init it, it is probably easier to just use `mem.set`
<muffindrake> Of course.
<mq32> oh. zig build is allergic to "moving the project folder"
doublex has quit [Ping timeout: 250 seconds]
jokoon has joined #zig
waleee-cl has joined #zig
<muffindrake> Strangely, my example segfaults only in debug mode, not release mode. How strange.
<muffindrake> I am running master.
muffindrake has quit [Quit: muffindrake]
muffindrake has joined #zig
return0__ has quit [Read error: Connection reset by peer]
return0e has joined #zig
doublex has joined #zig
stratact has joined #zig
knebulae has joined #zig
protty has joined #zig
<protty> Is there a way to use translate-c from build.zig? Can invoke it using `addSystemCommand()` but unsure how to pipe that result into a .zig file
<mq32> why would you need that? "prevent headers"?
<mq32> you can always convert-c just once and just include the resulting zig file
<protty> the system its running on and the file it translates can differ from machine to machine (jni.h)
<mq32> uarks :D
<mq32> addSystemCommand should probably do it, if it allows you to pipe
<mq32> in case of trouble, call a shell script
jokoon has quit [Quit: jokoon]
<protty> better q would be "how to pipe from addSystemCommand()"
FireFox317 has quit [Ping timeout: 245 seconds]
return0e_ has quit [Remote host closed the connection]
protty has quit [Ping timeout: 260 seconds]
dingenskirchen1 has joined #zig
dingenskirchen has quit [Ping timeout: 245 seconds]
dingenskirchen1 is now known as dingenskirchen
mahmudov has joined #zig
stianhj has quit [Quit: WeeChat 2.6]
THFKA4 has quit [Quit: WeeChat 2.4]
wootehfoot has joined #zig
bjorob has joined #zig
dtz has quit [Write error: Connection reset by peer]
mattmurr has quit [Read error: Connection reset by peer]
Demos[m] has quit [Read error: Connection reset by peer]
fengb has quit [Remote host closed the connection]
D3zmodos has quit [Remote host closed the connection]
Snektron has quit [Remote host closed the connection]
BitPuffin has quit [Remote host closed the connection]
lunamn has joined #zig
FireFox317 has joined #zig
traviss has quit [Quit: Leaving]
doublex has quit [Ping timeout: 250 seconds]
porky11 has joined #zig
doublex has joined #zig
lunamn_ has joined #zig
lunamn has quit [Ping timeout: 250 seconds]
FireFox317 has quit [Ping timeout: 245 seconds]
dimenus has quit [Ping timeout: 265 seconds]
doublex_ has joined #zig
doublex has quit [Ping timeout: 245 seconds]
ltriant has joined #zig
marijnfs has joined #zig
wilsonk has quit [Ping timeout: 245 seconds]
wilsonk has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
<leeward> Is there any kind of reflection support for structs? I have a packed struct of `u1`s and I want to be able to refer to its fields programmatically.
traviss has joined #zig
<mq32> sure, look at @typeInfo
jjido has joined #zig
<mq32> std.meta.fields is also an option afaik
<leeward> shiny, thanks
porky11 has quit [Quit: Leaving]
<traviss> leeward: did you end up with something like this? https://gist.github.com/travisstaloch/71a7a2bc260997abe06016c619b40bf2
<leeward> traviss: I didn't get to it, but it seems likely.
<leeward> distracted by other things
<mq32> pixelherodev, you there?
dimenus has joined #zig
bjorob has quit [Ping timeout: 240 seconds]
adamkowalski has joined #zig
<adamkowalski> Can anybody point me to some documentation for linking against a C library? I installed sdl2 with brew so it's in `/usr/local/Celler/sdl2/...`.
<dimenus> adamkowalski: `--library c` on the command line or `exe.linkSystemLibrary("c");` in your build.zig
<dimenus> oh, linking against a c library
<mq32> adamkowalski, you have to manually add the library, library search path and include by hand
<dimenus> have a look at my build.zig -> https://git.sr.ht/~dimenus/breakout/tree/master/build.zig
<dimenus> addLibPath / linkSystemLibrary
<daurnimator> andrewrk: #3644 passed CI after retriggering. would love to have that merged :)
<mq32> did i say "i love zig" today already?
<adamkowalski> I tried adding exe.linkSystemLibrary("sdl2");
<adamkowalski> How so I determine the search path for the system libraries?
<adamkowalski> whats the best practice with third party c libraries. I don't want to rely on my system location because then I can't deploy it
<adamkowalski> or it will have to be identical on the production machine right?
<daurnimator> mq32: no; your penalty is 10 "i love zigs" and a "I have faith in the ziguana"
<mq32> daurnimator: I've seen the word "ziguana" more often today than you! :D
<daurnimator> I just woke up, so probably
<mq32> haha, damn timezones
<adamkowalski> If I put an include folder in my project root, and a lib folder. Copy the contents from the brew install and put them into the respective directory, is that a good idea?
<daurnimator> Great ziguana, may he take off with every zig.
<dimenus> adamkowalski: `linkSystemLibrary` name is kind of misleading, it's basically just a compiled library
<dimenus> did you look at my build.zig?
<daurnimator> adamkowalski: IIRC linkSystemLibrary also consults pkg-config: does your library have a pkg-config file?
<daurnimator> adamkowalski: https://github.com/ziglang/zig/issues/3671 may be relevant for you...
<adamkowalski> dimenus yeah I'm reading through it. I thought I was following the pattern you wrote down
<adamkowalski> exe.addIncludeDir("include");
<adamkowalski> exe.addLibPath("lib");
<adamkowalski> exe.linkSystemLibrary("sdl2");
<dimenus> why are you using only part of the path?
<dimenus> vs `/usr/local/Cellar/sdl2/include`
<dimenus> my paths are relative to my project
<adamkowalski> it's relative now
<adamkowalski> I created include and lib directories at my project root
<adamkowalski> so its src/lib/include
<adamkowalski> I moved the files from sdl2/include to include
<dimenus> wait, in your project root or in src?
<adamkowalski> and same thing for lib
<dimenus> src is not your project root
<adamkowalski> project root
<adamkowalski> project root -[src | include | lib]
<dimenus> ok, does it link now?