I don’t know what tool I really need but I would like (to shoot my leg again) and just have force cast
So I have two C libraries (both of which I independently use) and one of them exposes API which takes as parameter type from another one
//lib1.h
struct lib1_struct {...}
//lib2.h
#include <lib1.h>
void lib2_func(lib1_struct);
I have two modules added via translate-c so in the end I have something like this in my zig file:
const lib1 = @import("lib1");
const lib2 = @import("lib2");
const tmp = lib1.lib1_struct {...};
lib2.lib2_func(tmp); // Error expected ...lib2.lib1_struct but got lib1.lib1_struct
I essentially know they are the same thing but can’t tell that to compiler
vulpesx July 14, 2026, 10:38am 2
it would be safe to ptr/bit cast them if they are c/extern structs with the same layout.
But ideally you shouldn’t have duplicate translated headers in the first place.
invlpg July 14, 2026, 11:44am 3
(post deleted by author)
invlpg July 14, 2026, 11:45am 4
Why not have just one translate-c module?
// c.h
#include <lib1.h>
#include <lib2.h>
const c = @import("c");
That way there’d only be one type.
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.