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/
ur5us has joined #zig
gazler_ has joined #zig
gazler has quit [Ping timeout: 265 seconds]
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
<v0idify> oh, i misread the error
<v0idify> yeah I saw that
<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
<ikskuh> yes, it can
<ikskuh> two ways:
<ikskuh> 1) @ptrCast(*align(1) u64, &input[0])
<ikskuh> which makes your u64 pointer align(1)
<ikskuh> 2) @ptrCast(*u64, @alignCast(@alignOf(u64), &input[0]))
<zags> hm, is #2 what I have?
<zags> isn't*
<ikskuh> kinda, yeah
<zags> that barfs at runtime
<ifreund> you need to make sure input is aligned to @alignOf(u64)
<fgenesis> so much syntax for what should be a simple cast o_O
<ifreund> fgenesis: I'd just use @intToPtr()
<ikskuh> and require
<ikskuh> var input : [32]u8 align(@alignOf(u64))
<ikskuh> fgenesis: it isn't a simple cast though ;)
<zags> i'll do the bitCast thing, thanks
<ikskuh> even if you're used to do it in C
<zags> yeah, I actually like that these casts stand out in an ugly way
<ikskuh> you've invoked a lot of UB before and you were just lucky that the compiler ignored that you did unaligned access
<ikskuh> start programming arm
<ikskuh> and you'll be happy to have these checks
<ifreund> note that @intToPtr() inserts the same alignement safety checks in safe build modes as @ptrCast() + @alignCast()
mmohammadi9812 has quit [Ping timeout: 240 seconds]
<ifreund> though if you make input aling(@alignOf(u64)) you won't need the @alignCast() and can just @ptrCast() directly
donniewest1 has joined #zig
<fgenesis> ikskuh: i was bitten by alignment issues before, so yea :D
<ikskuh> good :)
<ikskuh> :D
nvmd has joined #zig
mmohammadi9812 has joined #zig
zags has quit [Ping timeout: 240 seconds]
evbo has joined #zig
midgard has quit [Remote host closed the connection]
midgard has joined #zig
Akuli has joined #zig
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
waleee-cl has joined #zig
hnOsmium0001 has joined #zig
earnestly has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
kbd has joined #zig
kbd has quit [Client Quit]
kbd has joined #zig
wilsonk has quit [Ping timeout: 240 seconds]
Patrice_ has joined #zig
kragacles has quit [Quit: ZNC 1.8.2 - https://znc.in]
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?
dkibi has quit [Quit: leaving]
<ikskuh> nah, if you remove compiler-rt, still some symbols will be emitted
<ikskuh> so even without compiler-rt, there are some functions included
<ikskuh> mostly floating point stuff
<ikskuh> actually
<ikskuh> memcpy, memmove, memcmp, bcmp, memset and a whole bunch of stuff from math.h
<Gliptic> don't know if it still works
<ikskuh> sweet!
<ikskuh> works!
<Gliptic> good to know :)
<ikskuh> <3 thanks!
<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
<marijnfs> ikskuh: is that a library?
<marijnfs> sounds like that should be in std?
<ifreund> I believe that's the plan eventually
<marijnfs> the async example is interesting
Snetry has quit [Ping timeout: 246 seconds]
<ifreund> ikskuh: why are all the functions of the OsLogic structs in zig-network inline?
<ikskuh> ifreund: because they are only redirections
<ifreund> getFdSet seems to be a little more than that...
<ifreund> though that is windows only
<ikskuh> they are inlined into SocketSet
<ifreund> ok yeah I see what you're going for, I just don't agree that it matters here
<ikskuh> removes one level of stack trace
<ifreund> I'd probably have used @call() with .always_inline too myself
<ifreund> then you don't have to put it on all the functions of all the specializations
sord937 has quit [Quit: sord937]
<marijnfs> that does look like repetition
<marijnfs> how does @call help there?
<marijnfs> how would you implement testing with network code?
<ifreund> marijnfs: @call() allows you to inline functions at the callsite instead of needing to declare them with the inline keyword
<ifreund> to test network code, you probably need to build a bit of infrastructure
<ifreund> you can spin up several clients and a server from within a test "" {} block
Akuli has quit [Quit: Leaving]
<marijnfs> you're right, i can just start some threads and setup a two nodes
<marijnfs> what if i want to test what is send is the same received?
<marijnfs> i need to communicate between these threads for the test
ed_t has quit [Quit: Leaving]
<geemili> marijnfs: why not set up an expected value ahead of time and pass it to both threads?
frett27_ has joined #zig
Patrice_ has quit [Ping timeout: 258 seconds]
<marijnfs> geemili: that's actually smart
<marijnfs> the only thing is that the 'check' should wait for the 'write'
<marijnfs> you can't check if 1 is written before you received it
frett27_ has quit [Ping timeout: 272 seconds]
ur5us__ has quit [Ping timeout: 264 seconds]
Snetry has joined #zig
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
donniewest1 has quit [Ping timeout: 272 seconds]
jukan_ has joined #zig
jukan has quit [Ping timeout: 246 seconds]
donniewest1 has joined #zig