sebonirc has quit [Read error: Connection reset by peer]
midgard has joined #zig
sebonirc has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
cole-h has quit [Ping timeout: 272 seconds]
leon-p has joined #zig
earnestly has joined #zig
craigo_ has quit [Ping timeout: 256 seconds]
earnestly has quit [Ping timeout: 256 seconds]
earnestly has joined #zig
lanodan has quit [Quit: WeeChat 2.9]
jokoon has joined #zig
xackus has joined #zig
decentpenguin has quit [Ping timeout: 256 seconds]
jokoon2 has joined #zig
eio__ has joined #zig
jokoon has quit [Ping timeout: 272 seconds]
jokoon2 has quit [Ping timeout: 264 seconds]
craigo_ has joined #zig
waleee-cl has joined #zig
xackus has quit [Read error: Connection reset by peer]
xackus_ has joined #zig
waffle_ethics has joined #zig
oats has quit [Ping timeout: 256 seconds]
oats has joined #zig
<Gliptic>
anyone had problems with generated files in builds? I made a custom build step that writes to a .zig file, the .exe build has a dependOn on that step, but weirdly the zig compiler seems to skip one specific line of code in the generated file when it builds (???)
<Gliptic>
if I remove the generation from the build.zig and update the timestamp on the existing generated file, it's compiled correctly
vcarvalho has joined #zig
fputs has quit [Quit: Leaving]
<ifreund>
Gliptic: I do a lot of code generation in the build.zig with zig-wayland and haven't had any issues
<ifreund>
do you have your project online somewhere?
<Gliptic>
I'll look at how you do it, thanks
<Gliptic>
not yet, but I might scale it down to a testcase if I can't figure this out
<Gliptic>
it's always the same point in the file it's skipping, I had a variable declaration there before and then it was complaining about it missing
<Gliptic>
don't understand how it can be line-aligned
waffle_ethics has quit [Ping timeout: 264 seconds]
<ifreund>
it sounds like a caching issue tbh
<Gliptic>
yeah, if I don't do the "touch file", I get the same error even when not regenerating
<ifreund>
zig-wayland's code generation overwrites the generated files everytime the build.zig is run
<Gliptic>
yeah, that's what I'm doing too
<Gliptic>
hm, is wayland-scanner doing the generating
<Gliptic>
I write the file directly from Zig
waffle_ethics has joined #zig
dingenskirchen has quit [Quit: ZNC 1.8.1 - https://znc.in]
dingenskirchen has joined #zig
donniewest has joined #zig
<ifreund>
Gliptic: wayland-scanner generates some C code I link because of zig issue #131
<Gliptic>
just annoying, tried to figure this out since last night
<Gliptic>
zig should error on \n just like it does with \t
<Gliptic>
or accept \n
<ifreund>
I think you meain \r
<Gliptic>
no, \n
<Gliptic>
pretty sure there's no \r in there alone
<ifreund>
\r\n is windows, \n is unix
<Gliptic>
but I'll check exactly what happens
<Gliptic>
yes
<Gliptic>
actually, when I resave the file becomes all \n
<Gliptic>
I suppose it's because there's a mix of line endings
<Gliptic>
zig tries to guess which one to look for
<mikdusan>
from wikipiedia: lf, crlf, cr (apple II, classic macos, os9), rs (qnx), lfcr (let's be different Acorn and RISC OS), nl (IBM) and non-ascii newline for zx80
<g-w1>
yep, the doc comments are wrong. I think they are just trying to illustrate a point, not provide correct code since +- isn't valid either
<ed_t>
g-wl and all the tests for powi use inline values, none use expressions, When I use an expression it complains: error: invalid operands to binary expression: 'std.math.powi.error:27:44!i32'
<g-w1>
you must use try
<dutchie>
or catch unreachable if you are sure you can't over/underflow
<dvaun>
the pow file has some tests which illustrate the over/underflow occurring
<dvaun>
`lib/std/math/powi.zig`
<ed_t>
with a catch unreachable at the end of the expression (multiple powi and sqtr) I still get the errors
<dutchie>
you have to do it for each call
<ed_t>
that is a little insane
<ed_t>
imho
<dutchie>
the function returns an error union, not an integer, so you need to unwrap it every time
<ed_t>
its still insane. I care that the expression works. If any part fails with I just want to know the first error.
<ed_t>
doing any sort of math in zig is going to be a real pita
<dutchie>
that's what try is for
<ed_t>
try at the start of the express is not working - still get the same error
<dutchie>
`const w = std.math.sqrt(try std.math.powi(i32, cbx-c.p.x, 2) + try std.math.powi(cby - c.p.y, 2)) + 1;` should work
<ifreund>
missing the type arg for the second powi call
<dutchie>
ifreund: oops ty
<dutchie>
irc not a good code editor
<ed_t>
error: invalid operands to binary expression: 'std.math.powi.error:27:44!i32' and 'i32'
<ifreund>
you need try on both calls
<justin_smith>
ed_t: you need to unpack the error type (yeah try would help there)
<dutchie>
anyway just for squaring i'd write something like `const dx = cbx - c.p.x; const dy = cby - c.p.y; const w = std.math.sqrt(dx*dx + dy*dy) + 1`
<dutchie>
or use std.math.hypot
<dutchie>
(though that's only implemented for floats)
<ed_t>
yes and the second powi has the i32 now and i still get the error (try on both powi)
kbd has joined #zig
<ed_t>
I was tring to avoid temp constants
<g-w1>
your error should look like this error:linenum:col. use the col to see where you went wrong
<ed_t>
g-wl its pointing to the powi just after the first powi
<ed_t>
decomposing the second try causes the problem sqrt(try powi) works, sqrt(try powi + try powi) fails
earnestly has quit [Ping timeout: 256 seconds]
earnestly has joined #zig
<dutchie>
is this some dumb operator precedence thing
<dvaun>
So unwrap with `catch <some-default>` or just use `try`
<dvaun>
> An error set type and a normal type can be combined with the ! operator to form an error union type. Values of these types may be an error value, or a value of the normal type.
<Gliptic>
the , or ; is a sequence point (well, they call it something else now I think)
<Gliptic>
I mean, if it can see that there aren't side-effects, it can reorder them of course
<Gliptic>
because that follows the "as if" rule
<justin_smith>
dvaun: or sometimes even if with a |binding|
<dvaun>
i guess that would be needed fto check for underflow or overflow right?
<justin_smith>
Gliptic: that "as if" and its effect on multi threaded memory access whas what I was remembering
<justin_smith>
where the memory storage is treated as not having side effects, but in terms of shared memory access acts like an unpredictable side effect
<Gliptic>
that's down to the memory model
<justin_smith>
(or that was my weird mental model of the whole thing at least)
<Gliptic>
what counts as "as if" or not
<justin_smith>
yeah
<pixelherodev>
I think PrimaryTypeExpr is a bad name in the grammar, given that every valid PrimaryTypeExpr is a valid Expr...
<pixelherodev>
Rather, since PrimaryTypeExprs don't have to represent types
<motiejus>
hi all. I am trying to add a correct `-print-prog-name=ld` to zig, so it returns the appropriate linker for autotools. I am now struggling to relate the incoming args in `main.zig` to the appropriate linker (ld.lld/ld64.lld/lld-link/wasm-ld). I presume it should be resolved from `-target` somehow; any pointers?
<motiejus>
related question -- looks like `zig ld.lld --target=x86_64-linux-musl" is not a thing; I assume ld.lld is not supposed to be passed in target as its first param?
bitmapper has quit [Quit: Connection closed for inactivity]
waleee-cl has quit [Quit: Connection closed for inactivity]
<motiejus>
I think I found the answer to the first question -- `getObjectFormat(Target)`, second question remains :)
<g-w1>
what are you trying to do for the second one?
<g-w1>
build-lib or build-exe will link stuff when passed obj files
<motiejus>
I am trying to compile xz with `zig cc` and autotools
<motiejus>
see the `false cr <...>`? I am not experienced with libtool, but I think that's bad :)
<motiejus>
it's trivial to reproduce -- download xz archive, do `CC="zig cc" LD="zig build-lib" ./configure && make -j$(nproc)` on a somewhat fresh linux installation (debian:buster docker image works well)
<motiejus>
the only dependency then is make and zig itself (extracted from a nightly tarball)
<motiejus>
ok, found it: it was missing `AR`. Now with `AR="zig build-lib" LD="zig build-lib" CC="zig cc"` it is failing, because `zig build-lib cr <...>` is not a valid option, though it is for gnu ar
<motiejus>
i.e. `zig build-lib` does not understand `cr` command intended for ar
evbo has quit [Read error: Connection reset by peer]
frett27 has joined #zig
evbo has joined #zig
jukan_ has joined #zig
jukan has quit [Ping timeout: 240 seconds]
blackbeard420 has quit [Quit: ZNC 1.8.0 - https://znc.in]
blackbeard420 has joined #zig
waleee-cl has joined #zig
ur5us has joined #zig
xackus_ has joined #zig
waffle_ethics has quit [Ping timeout: 272 seconds]
cole-h has joined #zig
<ed_t>
how would you define a constant array of stings, eg a[0]="somestring" etc
tnorth_ has quit [Ping timeout: 260 seconds]
waffle_ethics has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
waffle_ethics has quit [Ping timeout: 256 seconds]
r0bby has quit [Ping timeout: 264 seconds]
r0bby has joined #zig
xackus__ has joined #zig
xackus_ has quit [Read error: Connection reset by peer]
<ugla>
const some_strings = [_][]const u8{"some string", "some other string"};
<ed_t>
thanks ugla
<ed_t>
can the type be for i? for (xxx) |y, i|
<ugla>
I think so
<ed_t>
if so I cannot figure out how i32:i fails i:i32 fails
<justin_smith>
ed_t: are you asking why i can't be i32 in "for (xxx) |y, i|" ?
<justin_smith>
I think i is always usize(?) but when I need iN I use @intCast(iN, i)
Akuli has quit [Quit: Leaving]
sord937 has quit [Quit: sord937]
vcarvalho has quit [Quit: WeeChat 2.9]
frett27 has quit [Ping timeout: 240 seconds]
Snetry- has quit [Ping timeout: 265 seconds]
donniewest has quit [Quit: WeeChat 3.0]
xackus_ has joined #zig
squeek502 has quit [Remote host closed the connection]
xackus__ has quit [Read error: Connection reset by peer]
squeek502 has joined #zig
blueberrypie has quit [Quit: Ping timeout (120 seconds)]
blueberrypie has joined #zig
xentec_ has joined #zig
xentec has quit [Quit: memento mori]
ur5us_ has joined #zig
Snetry has joined #zig
ur5us has quit [Remote host closed the connection]
hnOsmium0001 has quit [Read error: Connection reset by peer]
jzelinskie has quit [Ping timeout: 260 seconds]
ovf has quit [Disconnected by services]
jzelinskie_ has joined #zig
eddyb[legacy] has quit [Ping timeout: 264 seconds]