translate-c macro `parseCCondExpr` doesn't handle condition being an int
xess0fd00m opened this issue · comments
xess0fd00m commented
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Sorry if I make any mistakes, that's my first bug report.
The issue has been initially posted in the Discord channel: https://discord.com/channels/605571803288698900/1259557554514825267
I have been trying to use the python C api with zig and getting all sorts of errors with some #defines .
I was able to put together a simple pointless example to show what happens:
C code:
int test(int a) {
if (a > 10) {
return 1;
};
if (a < 10) {
return 0;
};
}
#define aaa(fp) ( test(fp) ? "pass" : "fail")
And in zig:
const cc = @cImport({
@cInclude("/shared/programming/zython/a.c");
});
pub fn main() void {
_ = cc.aaa(10);
}
I get the error:
/home/xess0fd00m/.cache/zig/o/eae9223db4ed68d2f6561d5ead7f200e/cimport.zig:12146:51: error: expected type 'bool', found 'c_int'
pub inline fn aaa(fp: anytype) @TypeOf(if (@"test"(fp)) "pass" else "fail") {
~~~~~~~^~~~
src/ttt.zig:22:15: note: called from here
_ = cc.aaa(10);
~~~~~~^~~~
I tried to edit the generated zig code and it works:
Expected Behavior
Not having to edit the generated Zig code to call the C macro.