bitmapper has quit [Quit: Connection closed for inactivity]
<ed_t>
why no (not x) where x:bool ? or am I missing something
brzg has joined #zig
<ed_t>
! found it
<andrewrk>
! is not control flow, but `and` and `or` are
jukan has joined #zig
jukan_ has quit [Ping timeout: 246 seconds]
brzg has quit [Quit: leaving]
bitmapper has joined #zig
brzg has joined #zig
cole-h has quit [Ping timeout: 258 seconds]
<ed_t>
andrewrk came across this (!) when trying if (not x) and had to use if (!bool) how is that not flow control (not disputing you I would just like to understand the reasoning)
<andrewrk>
`if` is control flow. inverting a boolean value is not.
<andrewrk>
`and` and `or` are short-circuiting, which means the right-hand side does not evaluate if the left hand side makes it not necessary
<brzg>
is it intentional or a bug/limitation that i can't get `*Bar` (only `*const Bar`) from element of `Foo` struct which is `?Bar` through `if (...) |...| {...}`, even if the `Foo` is available as `*Foo` or `Foo`?
<ed_t>
andrewrk I have been coding a very long time (eg. my first computer came with 1k memory). Have used all sorts of languages over the years. zig has its good points but it is very very picky - compiler is fast though which helps.
jukan has quit [Read error: Connection reset by peer]
jukan_ has joined #zig
v0idify has joined #zig
<brzg>
never mind i didn't fully understand `if`
<v0idify>
hey, i'm using a C function which takes `*const void`, however passing a value tells me that they are not the same size (which is correct, *c_void in zig is 0-byte). how can I bypass this?
a_chou has joined #zig
jukan has joined #zig
jukan_ has quit [Ping timeout: 240 seconds]
<andrewrk>
v0idify, the C function should take `*const c_void`, not `*const void`, which is a different concept
<andrewrk>
in zig, c_void can be defined by `const c_void = @Type{.Opaque};`
<andrewrk>
*c_void in zig is not 0-byte, but *void is
<andrewrk>
oops, I meant `opaque{}` not `@Type{.opaque}`
<v0idify>
*comptime_int doesn't have memory, that's why it failed
<v0idify>
thanks!
dvaun has joined #zig
philtor has quit [Read error: Connection reset by peer]
philtor has joined #zig
midgard has quit [Ping timeout: 272 seconds]
midgard has joined #zig
greeb has quit [Ping timeout: 246 seconds]
earnestly has quit [Ping timeout: 240 seconds]
brzg has quit [Quit: leaving]
<v0idify>
is there a way to import a C header in the current directory (#include "" vs #include <>)?
osa1 has quit [Ping timeout: 256 seconds]
freshmaker666 has joined #zig
ur5us_ has joined #zig
<g-w1>
addIncludeDir in build.zig or -I on the cli
ur5us has quit [Ping timeout: 260 seconds]
fgenesis has joined #zig
gert_ has joined #zig
<v0idify>
g-w1, thanks
a_chou has quit [Ping timeout: 246 seconds]
travv0 has joined #zig
xackus_ has joined #zig
xackus has quit [Ping timeout: 240 seconds]
techtirade has quit [Ping timeout: 264 seconds]
midgard has quit [Read error: Connection reset by peer]
midgard has joined #zig
gert_ has quit [Quit: WeeChat 3.0]
<andrewrk>
if anyone's looking for some small, impactful contributions, I could use some help with #7920. look at the latest commit for example. idea is to start uncommenting parser_test.zig (zig fmt) test cases one by one
<andrewrk>
in summary all of zig fmt has to get rewritten with the new memory layout. it's a big chore, but at least it's pretty straightforward
techtirade has joined #zig
notzmv has quit [Ping timeout: 260 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
notzmv has joined #zig
mmohammadi9812 has quit [Ping timeout: 264 seconds]
mmohammadi9812 has joined #zig
a_chou has joined #zig
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #zig
mmohammadi9812 has quit [Client Quit]
Yardanico has quit [Ping timeout: 264 seconds]
a_chou has quit [Remote host closed the connection]
kbd has joined #zig
<kbd>
Is there any kind of --verbose option for zig test that will show the names of the tests that are run?
Yardanico has joined #zig
_fritchie has quit [Remote host closed the connection]
_fritchie has joined #zig
semarie has quit [Ping timeout: 240 seconds]
semarie has joined #zig
<mikdusan>
just take away the tty; so if using zsh: zig test foo.zig |& cat
a_chou has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
a_chou has quit [Remote host closed the connection]
osa1 has joined #zig
cole-h has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
sord937 has joined #zig
belgin has joined #zig
ur5us_ has joined #zig
belgin has quit [Quit: Leaving]
belgin has joined #zig
<kbd>
mikdusan 🤔
<kbd>
why *screams at clouds*
belgin has quit [Quit: Leaving]
earnestly has joined #zig
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #zig
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
casaca has quit [Ping timeout: 240 seconds]
teratorn has quit [Ping timeout: 272 seconds]
ur5us__ has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
cole-h has quit [Ping timeout: 240 seconds]
teratorn has joined #zig
ur5us__ has quit [Ping timeout: 240 seconds]
Stephie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
casaca has joined #zig
<daurnimator>
kbd: classic usecase of `isatty`
mmohammadi9812 has joined #zig
<ifreund>
huh? zig allows having functions with the same name as fields?
<ifreund>
isn't this ambiguous?
<ifreund>
say the field is a function pointer, does my_struct.foo() call the MyStruct.foo or the function pointer stored in field foo
<ikskuh>
ifreund: it's not. you cannot access fields without a struct pointer or value
<ikskuh>
ah, yeah
<ikskuh>
true, that case is
<ifreund>
yeah...
<ifreund>
I guess I should open an issue
<ifreund>
looks like the field shadows the decl in this case
<ifreund>
#6966 would also fix this
<ifreund>
#705 already exists :)
<ifreund>
well no, that doesn't actually propose to make that a compile error, just improve the UX
gazler__ has joined #zig
gazler_ has quit [Ping timeout: 264 seconds]
<pixelherodev>
Thought: compiling libc takes a while, but only happens once, right? Why is stdlib different?
<pixelherodev>
Why does compiling zig stdlib compile each function as part of the consumer?
<pixelherodev>
(excepting comptime, to be clear)
<pixelherodev>
Ah, never mind, I don't think either upstream compiler's design allows for that in a reasonable manner (because of comptime)
<ikskuh>
you cannot precompile zig code
<ikskuh>
you can only pre-parse it into an AST
<ikskuh>
no object format possible
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
kbd has joined #zig
kbd has quit [Client Quit]
zags has joined #zig
<zags>
Hey, I'm porting a reinterpret_cast thing, input is 64 raw bytes array which I need to treat as a pointer to 64 bit integer.
<zags>
I tried `@ptrCast(*const u64, @alignCast(@alignOf(u64), &input[0]));` but get `panic: incorrect alignment` at runtime.
<zags>
Input is a `[32]u8`
<zags>
Where's my basic mistake? :D
<zags>
32 raw bytes*
<ikskuh>
your [32]u8 must not be aligned to @alignOf(u64)
<ikskuh>
so u64 is probably align 4 or 8
<ikskuh>
[32]u8 has align(1)
<ikskuh>
you can also do this:
<ikskuh>
@bitCast(u64, input[0..@sizeOf(u64)].*)
<zags>
cool, but CAN ptrCast work? I really just want the first 8 bytes of the array to be the bytes for my u64
midgard has quit [Read error: Connection reset by peer]
midgard has joined #zig
donniewest1 has quit [Quit: WeeChat 3.0.1]
<kbd>
daurnimator: "classic usecase of `isatty`" - is it? Been programming a long time at this point, familiar with `isatty`, never seen anyone use it like that to mean "verbose test output". Could stand to be documented :)
<ifreund>
kbd: in this case it means "don't use escape sequences to overwrite the same line repeatedly because the output is being piped"
kragacles has joined #zig
<kbd>
👍
donniewest1 has joined #zig
<semarie>
why std.c.getErrno() is u16 instead of c_int ? I am looking at zeromq (https://github.com/zeromq/libzmq) and it is using errno for application specifics error using high values (like 156384765)
geemili has joined #zig
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
<ifreund>
good question, POSIX says it's an int right?
<ifreund>
or ISO C or whatever
<semarie>
I just checked POSIX-2013. yes, it is expected to be a int
<semarie>
https://man.bsd.lv/POSIX-2013/errno => "Many functions provide an error number in errno, which has type int and is defined in <errno.h>"
<ifreund>
semarie: looks like std.c._errno gives you the int
<semarie>
oh, it is public. cool :)
<semarie>
so I should be able to workaround. thanks ifreund
<ifreund>
no problem, I think that std.c.getErrno() should probably just return a c_int tbh
<ifreund>
either that or some unsigned type that can only represent the positive values of a c_int
<ifreund>
but that seems overcomplex
kbd_ has joined #zig
kbd has quit [Ping timeout: 258 seconds]
frett27_ has joined #zig
Patrice_ has quit [Ping timeout: 272 seconds]
cole-h has joined #zig
<fengb>
It's converted to each platform
<ikskuh>
andrewrk: if i compile a wasm32-freestanding-none module, a lot of stuff gets emitted into the binary
<ikskuh>
is this a already-known problem/issue on github?
<Gliptic>
ikskuh: hm, I tested it and the exported function was not exported any longer in the .wasm
<ikskuh>
for me, it was
mmohammadi9812 has quit [Remote host closed the connection]
<andrewrk>
there is definitely an issue here though
mmohammadi9812 has joined #zig
<andrewrk>
I don't remember exactly what the plan is but suffice to say when things are working as desired there won't be unused symbol bloat in outputted wasm
<ikskuh>
yep
Patrice_ has joined #zig
frett27_ has quit [Ping timeout: 272 seconds]
ur5us__ has joined #zig
marijnfs has joined #zig
<marijnfs>
how are the network capabilities of zig holding up?
<marijnfs>
i want to do udp hole punching
<ikskuh>
use zig-network
<ikskuh>
you can do that with it
<ikskuh>
but note that you need some central server or side channe for this
<marijnfs>
i'm implementing a dht
<marijnfs>
so nodes can use each other for this
<marijnfs>
there should always be some nodes that have open ports