<dominikh>
semi-related, I was wondering about the viability of this approach: instead of using @cImport, manually use translate-c, and then modify the output to clean it up – more idiomatic type names, adding methods, changing C pointers to the appropriate Zig pointers.
ur5us has joined #zig
johnburton has quit [Ping timeout: 256 seconds]
johnburton has joined #zig
<g-w1>
I just tried this, I think this works: `extern fn foo(bar: u32) u32; const baz = foo; baz(bar);`
dbandstra has joined #zig
a92 has joined #zig
ur5us_ has joined #zig
ur5us has quit [Ping timeout: 264 seconds]
<dominikh>
oh that's neat
geert_ has joined #zig
dpdp has joined #zig
geert_ has quit [Ping timeout: 268 seconds]
<dpdp>
im calling var value_tree = try json_parser.parse(json); and trying to figure out which json type value_tree.root is.
<dpdp>
every attempt at using @TypeOf and/or @Tagtype has failed. can someone point me in the right direction
<dpdp>
(using zig HEAD as of a month or two ago, so newer than 0.6)
<dpdp>
the most recent attemtp being "if (@TypeOf(value_tree.root) == std.json.Value.Array) {" => incompatible types: 'type' and '@TagType(std.json.Value)'
<a92>
How did these attempts fail? Was there an error message?
<g-w1>
i think this is the error: incompatible types: 'type' and '@TagType(std.json.Value)'
<g-w1>
dpdp: are you using the standard library json parser?
<dpdp>
yup. var json_parser = std.json.Parser.init(allocator, false);
<dbandstra>
`if (value_tree.root == .Array)` should work
<g-w1>
It is just an enum so u can just match the tags
<dpdp>
dbandstra: if ... == .Array worked. thanks! I was banging my head agaist that for a long time
<dpdp>
not sure why std.json.Value.Array wouldnt be equivalent
<dpdp>
hmm actually that does seem to be equivalent o^O
<dbandstra>
that should work too
<dbandstra>
but you don't use TypeOf because you're actually trying to look at the runtime value of `value_tree.root`
<dpdp>
laptop battery almost dead. goota run. thx for the help.
dpdp has quit [Quit: leaving]
<andrewrk>
I think the macos regression (causing failing CI) is fixed with my latest commit
frmdstryr has quit [Ping timeout: 240 seconds]
<g-w1>
Just out of curiousity, how much longer does that make it take?
xackus_ has quit [Ping timeout: 260 seconds]
ur5us__ has joined #zig
ur5us_ has quit [Ping timeout: 240 seconds]
xackus_ has joined #zig
a92 has quit [Quit: Leaving]
l1x has quit [Ping timeout: 260 seconds]
strmpnk has quit [Read error: Connection reset by peer]
nikki93 has quit [Read error: Connection reset by peer]
nikki93 has joined #zig
strmpnk has joined #zig
l1x has joined #zig
dputtick has quit [Ping timeout: 260 seconds]
dputtick has joined #zig
earnestly has quit [Ping timeout: 256 seconds]
CmdrCrisp has quit [Ping timeout: 264 seconds]
stripedpajamas has joined #zig
stripedpajamas has quit [Read error: Connection reset by peer]
dbandstra has quit [Quit: leaving]
CodeSpelunker has joined #zig
rx_ has joined #zig
rx_ has quit [Quit: rx_]
kristoff_it1 has quit [Ping timeout: 240 seconds]
xackus has joined #zig
xackus_ has quit [Ping timeout: 240 seconds]
ur5us__ has quit [Ping timeout: 264 seconds]
CodeSpelunker has quit [Quit: CodeSpelunker]
dbandstra has joined #zig
xackus has quit [Read error: Connection reset by peer]
xackus has joined #zig
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<pjz>
x
waleee-cl has quit [Quit: Connection closed for inactivity]
mm4 has joined #zig
mm4 has quit [Remote host closed the connection]
geert_ has joined #zig
geert_ has quit [Read error: Connection reset by peer]
Patrice_ has quit [Ping timeout: 258 seconds]
geert_ has joined #zig
frett27__ has quit [Read error: Connection reset by peer]
frett27 has joined #zig
frett27 has quit [Remote host closed the connection]
frett27 has joined #zig
osa1 has joined #zig
frett27 has quit [Ping timeout: 268 seconds]
cole-h has quit [Ping timeout: 240 seconds]
wilsonk has left #zig [#zig]
osa1 has quit [Remote host closed the connection]
osa1 has joined #zig
lucid_0x80 has joined #zig
dead10cc has joined #zig
dead10cc has left #zig [#zig]
x2C25 has quit [Ping timeout: 260 seconds]
dbandstra has quit [Quit: leaving]
Kingsquee has quit []
x2C25 has joined #zig
Kingsquee has joined #zig
Kingsquee has quit []
wilsonk has joined #zig
wilsonk is now known as Guest52885
Guest52885 has left #zig [#zig]
frett27 has joined #zig
frett27 has quit [Quit: Leaving]
xackus has quit [Read error: Connection reset by peer]
xackus has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
xackus has quit [Quit: Leaving]
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #zig
gazler has joined #zig
gazler_ has quit [Ping timeout: 260 seconds]
xackus has joined #zig
<ask6155>
hello
<alexnask[m]>
hi
<ask6155>
there is a function which needs two *ints (x,y) so it can put values into it. so I decided to make a zig struct called vec2. it had two fields x,y both as c_int... what should I pass to the function?
<ask6155>
do I pass the struct.x or *struct.x?
xackus has quit [Quit: Leaving]
xackus has joined #zig
benjamin-l has quit [Ping timeout: 240 seconds]
dutchie has quit [Ping timeout: 240 seconds]
dutchie_ has joined #zig
dutchie_ is now known as dutchie
<alexnask[m]>
ask6155: If the function takes *int, you should pass &struct.x
<ask6155>
okay it works now, thanks
benjamin-l has joined #zig
jjsullivan has quit [Ping timeout: 260 seconds]
earnestly has joined #zig
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
frmdstryr has joined #zig
Kena has joined #zig
<Kena>
Hello bits and bytes people. Please what does `unreachable` do in ReleaseSmall mode?
<Kena>
No-op means it has zero cost in time and space, right?
<Kena>
0 bytes allocated and 0 microprocessor cycle use I mean.
<frmdstryr>
Not sure, I think it depends on whether the optimizer can remove it completely.
<g-w1>
to be sure, you could try it on zig.godbolt.org
<ifreund>
Kena: unreachable allows the compiler to generate code as if the given state is truly impossible to reach. This means that there is no code generated for the unreachable statement itself but it allows surrounding codegen to potentially be done more efficiently
<ifreund>
if your program does reach this state you told the compiler was unreachable though, that is UB and truely anything could happen
<ifreund>
to the contrary, the llvm docs state exactly what it does
<ifreund>
It has "no defined sematics" i.e. reaching it is UB
waffle_ethics has joined #zig
<frmdstryr>
Saying what it doesn't do isn't what it does :)
<ifreund>
well that's the point, what it does is undefined
<Kena>
Thank you frmdstryr, g-w1, ifreund
x2C25 has quit [Ping timeout: 268 seconds]
<Kena>
By the way g-w1, do you have a degree in software engineering, computer ingineering, computer science or did you learn programming yourself? I'm still impressed that you're developing a compiler.
haliucinas has quit [Remote host closed the connection]
osa1 has quit [Read error: Connection reset by peer]
osa1 has joined #zig
haliucinas has joined #zig
skuzzymiglet has joined #zig
marnix has quit [Ping timeout: 268 seconds]
marnix has joined #zig
waffle_ethics has quit [Ping timeout: 272 seconds]
skuzzymiglet has quit [Read error: No route to host]
waffle_ethics has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
donniewest has joined #zig
cole-h has joined #zig
xackus has joined #zig
skuzzymiglet has joined #zig
Akuli has joined #zig
osa1 has quit [Quit: osa1]
hnOsmium0001 has joined #zig
zippoh has quit [Ping timeout: 260 seconds]
waleee-cl has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 264 seconds]
<ifreund>
tdeo: just ported my scanner to use your xml parser which is working great. Do you know how best I should handle licensing? ISC is "equivalent" to MIT according to wikipedia but I probably still have to ship two LICENSE files or something
Kena has quit [Remote host closed the connection]
Akuli has quit [Quit: Leaving]
<g-w1>
Kena: I have done all my computer science by myself with no formal stuff. But my compiler is not that big. Its just for fun to see how things work.
moinstar has joined #zig
waffle_ethics has quit [Ping timeout: 240 seconds]
waffle_ethics has joined #zig
<Ristovski>
Just out of curiosity, is it possible to "serialize" a struct for example (into something like a byte array, for sending via network etc)
<pixelherodev>
For sure
<Ristovski>
I think I have heard of this on some github issue, maybe even here as well, but I wonder how custom types would be handled
<pixelherodev>
Look at what happens with e.g. `std.debug.warn("{}", .{some_struct_instance});`
<pixelherodev>
If you define a `pub fn format` in the struct, it'll use that to serialize it, I believe
<Ristovski>
Yeah exactly, it seems like it would be fairly 'easy'
<pixelherodev>
Check out fmt.zig in the standard library
<Ristovski>
Hmm, will do, thanks!
<pixelherodev>
:)
<Ristovski>
I have some C++ code that uses capnproto for serialization, which I would love to port to Zig with no external deps
<Nypsie[m]>
Ristovski: There's also std.serialization that you could check out
<Ristovski>
Nypsie[m]: oh huh, how did I miss that? neat
benjamin-l has quit [Ping timeout: 240 seconds]
dumenci has quit [Ping timeout: 240 seconds]
tracernz has quit [Ping timeout: 272 seconds]
tracernz has joined #zig
tane has joined #zig
lucid_0x80 has joined #zig
CmdrCrisp has joined #zig
skuzzymiglet has quit [Ping timeout: 256 seconds]
CmdrCrisp has quit [Ping timeout: 264 seconds]
LanceThePants has quit [Read error: Connection reset by peer]
<companion_cube>
although zig serialization is not standard, is it? if you need to talk to other programs it can be a problem
<Ristovski>
ugla: Oh nice! Well, "no deps" would just be an extra nice thing to have (or in this case - to not have :P)
geert_ has quit [Ping timeout: 264 seconds]
<andrewrk>
latest CI failure on macOS is this message: Assertion failed: (timeout != -1), function uv__io_poll, file ../deps/uv/src/unix/kqueue.c, line 231
<andrewrk>
wtf? we have no libuv anywhere in zig or in the ci script
<Ristovski>
perhaps in some macos lib?
<g-w1>
Why do all the bugs need to be right before the release? :(
<andrewrk>
std lib tests do not link any libs other than libSystem
<Ristovski>
ideally, it should correspond to the latest master/nightly release
<andrewrk>
I bumped it down to 0.7.0 milestone, but no promises that I'll have time to do it by the release - lots of other things to get done too
<scientes>
Ristovski, look in the ci folder
<Ristovski>
Hmm, is -femit-docs broken on master? `zig test lib/zig/std/std.zig -femit-docs -fno-emit-bin` fails with 'Terminated' after semantic analysis (also --output-dir has been removed)
<Ristovski>
Oh actually, that might be caused by earlyoom :/ I assume this might be quite memory-intensive
<Ristovski>
Yup, too memory intensive for my measly 8GB of ram
<g-w1>
can someone tell me which one of these flags cause the output binary to be in a different place please? /drone/src/build/zig build-exe -cflags -std=c99 -- /drone/src/test/standalone/shared_library/test.c --library /drone/src/test/standalone/shared_library/zig-cache/o/06dd1d74d6beba6ec58d8ec19bc295fc/libmathtest.so.1.0.0 -rpath /drone/src/test/standalone/shared_library/zig-cache/o/06dd1d74d6beba6ec58d8ec19bc295fc
<g-w1>
--library c --cache-dir /drone/src/test/standalone/shared_library/zig-cache --name test --enable-cache
<g-w1>
my pr is failing because of it and I want to know where the output binary would be, because it is not $pwd/test? https://github.com/ziglang/zig/pull/6716
frett27 has joined #zig
<ifreund>
--cache-dir i assume
<g-w1>
you think it makes it output to $cache-dir/bin/test?
<ifreund>
that would be my guess
ur5us__ has joined #zig
waffle_ethics has quit [Ping timeout: 264 seconds]
skuzzymiglet has quit [Read error: No route to host]
benjamin-l has joined #zig
ur5us__ has quit [Remote host closed the connection]
ur5us__ has joined #zig
frett27 has quit [Ping timeout: 264 seconds]
<Ristovski>
Can someone confirm -femit-docs works on latest master? I tried it on a beefier machine and I get 'error: unable to find '{io,fs,os,json,net,linux}/test.zig''
<Ristovski>
Or perhaps that is no longer the way to generate the docs
CmdrCrisp has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]