ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
mnoronha has joined #zig
hoppetosse has quit [Ping timeout: 245 seconds]
mnoronha has quit [Ping timeout: 272 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
very-mediocre has joined #zig
MajorLag has quit [Read error: Connection reset by peer]
MajorLag has joined #zig
davr0s has joined #zig
jjido has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Ichorio has joined #zig
unique_id has quit [Remote host closed the connection]
unique_id has joined #zig
unique_id has quit [Remote host closed the connection]
jjido has joined #zig
mal`` has quit [Ping timeout: 240 seconds]
redj has quit [Ping timeout: 240 seconds]
Hejsil has joined #zig
unique_id has joined #zig
very-mediocre has quit [Ping timeout: 256 seconds]
redj has joined #zig
<unique_id> I just rewrote a simple file merging application in Zig (from C++). Less than 100 lines. Comparing the difference is a lot of fun. I'm much happier with the Zig code.
<unique_id> There's a lot of possible i/o errors and the Zig code just looks more robust to me and I know what it's doing.
<c15ade4> :)
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<redj> unique_id: you can't show this C++ vs Zig for all to see?
<unique_id> I'll do it next time, sorry. I find that the explicit try statements make things much clearer. I also found a great use for orelse.
Hejsil has quit [Ping timeout: 256 seconds]
<unique_id> I'm building a zig library and then I'm going to depend on it from another zig project. I've never done this before, I don't know what to do.
<unique_id> the zig library has an index.zig file. From the main project I'd like to: @import("Library"), in the same way that you do @import("std")
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has joined #zig
davr0s has joined #zig
<unique_id> I figured it out. Packages. exe.addPackagePath
Ichorio has quit [Ping timeout: 244 seconds]
redj has quit [Ping timeout: 260 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
redj has joined #zig
unique_id has quit [Remote host closed the connection]
unique_id has joined #zig
very-mediocre has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Shoop has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Shoop has quit [Ping timeout: 256 seconds]
davr0s has joined #zig
adrusi has quit [Quit: ZNC 1.7.1 - https://znc.in]
adrusi has joined #zig
geocar has quit [Quit: Connection closed for inactivity]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jjido has joined #zig
davr0s has joined #zig
unique_id has quit [Ping timeout: 268 seconds]
unique_id has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
srgpqt has joined #zig
<srgpqt> Hi all. Trying to use a c library from zig and can't seem to figure out how to deal with pointers to opaque types. The lib has a function that returns a pointer to an opaque type, and another function that accepts that pointer. When i try pass the pointer to that function, the compiler tells me "error: unknown-length pointer to opaque"
<andrewrk> hi srgpqt. here's an example of what's not allowed: [*]c_void
<andrewrk> what is allowed: *c_void
<andrewrk> you may also be interested in https://github.com/ziglang/zig/issues/1059
<srgpqt> yeah i already read through that issue, thanks
<andrewrk> I'm happy to help further if I can see some code snippets and error messages
<andrewrk> until #1059 is resolved, it might be worth your time to translate-c offline and save the results in a .zig file that you manually edit to fix up the pointer types
<srgpqt> still not clear exactly what syntax i need to make it work, perhaps i would have to manually fix up with translate-c? It's something like this:
<srgpqt> struct Base { int value; }
<srgpqt> typedef struct Foo Foo; // opaque type extending Base
<srgpqt> Foo *newFoo(void);
<srgpqt> void setBaseValue(Base *f, int value);
<srgpqt> so i want to call newFoo from zig, and pass that value to setBaseValue
<andrewrk> srgpqt, you'll need to @ptrCast(*Base, foo)
<andrewrk> it's unfortunate that setBaseValue has ?[*]T: pub extern fn setBaseValue(f: ?[*]struct_Base, value: c_int) void;
<andrewrk> better would be: pub extern fn setBaseValue(f: *struct_Base, value: c_int) void;
<andrewrk> this is what #1059 is talking about
<srgpqt> yeah
<srgpqt> i had already tried @ptrCast, it gives me "error: cast increases pointer alignment"
davr0s has joined #zig
<srgpqt> I may have worked around it with some intermediate variables using @ptrCast and @alignCast... guess i'll find out
<andrewrk> srgpqt, ah ok that's the real issue - pointer alignment. I think you just have to settle for a @ptrCast and an @alignCast
<andrewrk> there's a better way to design a C API so that this does not happen
<srgpqt> For sure, but it would be nice if there was a convenient escape hatch for this use case. I'll try making a small helper function that does the casts for my situation
<srgpqt> Thanks
<andrewrk> agreed. #1059 describes that escape hatch
very-mediocre has quit [Ping timeout: 256 seconds]
srgpqt has quit [Ping timeout: 252 seconds]
karlguy has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
m4ge123 has joined #zig
davr0s has joined #zig
ephetic has joined #zig
unique_id has quit [Quit: Konversation terminated!]
ephetic has quit [Quit: ephetic]