Open foodornt opened 1 year ago
I have a similar bug trying to use GTK 4 (zig 0.10.1)
unable to translate C expr: unexpected token ')'
At /usr/include/glib-2.0/gobject/gtype.h
line 2504
This is the macro failing :
# define _G_TYPE_CIC(ip, gt, ct) \
((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
I also have issue with glib-2.0/gobject/gtype.h
, the same macro as @uben0 (not the same line but still _G_TYPE_CIC)
(using zig 0.12.0-dev.415+5af5d87ad)
The error is
unable to translate C expr: unexpected token ')' pub const _G_TYPE_CIC = @compileError("unable to translate C expr: unexpected token ')'"); // /usr/include/glib-2.0/gobject/gtype.h:2647:11`
With translate-c, I see that of these 9 macros, 6 are translated to @compileError("unable to translate C expr: unexpected token ')'");
# define _G_TYPE_CIC(ip, gt, ct) ((ct*) (void *) ip) //->unexpected token ')'
# define _G_TYPE_CCC(cp, gt, ct) ((ct*) (void *) cp) //->unexpected token ')'
...
# define _G_TYPE_CIC(ip, gt, ct) \
((ct*) (void *) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) //->unexpected token ')'
# define _G_TYPE_CCC(cp, gt, ct) \
((ct*) (void *) g_type_check_class_cast ((GTypeClass*) cp, gt)) //->unexpected token ')'
...
#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip)) //OK
#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl)) //OK
#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class)) //->unexpected token ')'
#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) )->g_class, gt)) //->unexpected token ')'
#define _G_TYPE_CIFT(ip, ft) (g_type_check_instance_is_fundamentally_a ((GTypeInstance*) ip, ft)) //OK
Also I'm new to Zig so I may be doing something wrong.
EDIT: I manually translated the macro
pub inline fn _G_TYPE_CIC(ip: anytype, gt: anytype, comptime ct: type) *ct {
const p = @as(*GTypeInstance, @ptrCast(ip));
return @as(*ct, @ptrCast(g_type_check_instance_cast(p, gt)));
}
And changed it inside the zig_cache, but Idk if it will be stable, nor if my translation is perfect x)
I have this too, just writing a test app to see if GTK works.
I can confirm that the _G_TYPE_CIC
issue is still the case with Zig 0.14.0-dev.130+cb308ba3a and GTK+3
Same problem here using gtk4 with Zig 0.14.0-dev.850+ddcb7b1c1
Zig Version
0.9.1
Steps to Reproduce and Observed Behavior
Try to compile my project https://github.com/foodornt/zigbug
(have libpipewire v 3 installed)
Expected Behavior
To translate C code just fine, though it's stuck at this line:
spa/pod/builder.h:72:9