Compiler error with C library using variadic arguments in a macro

I’m trying to use the clay library, but I’m getting a compiler error because of this macro:

#define CLAY_SIZING_FIT(...) (CLAY__INIT(Clay_SizingAxis) { .size = { .minMax = { __VA_ARGS__ } }, .type = CLAY__SIZING_TYPE_FIT })

Error:

.zig-cache/o/fdb0e7c4500e362a3a0d1ce76bab39ee/cimport.zig:5589:29: error: unable to translate C expr: expected ')' instead got '...'
pub const CLAY_SIZING_FIT = @compileError("unable to translate C expr: expected ')' instead got '...'");

Doesn’t Zig support C macros with variadic arguments? How can I work around that?

1 Like

Not sure how to make this work, but looking at the zig bindings suggests that this is not possible. Instead of using the macro, don’t cimport the files and use extern fn for the C functions and create your own “macro” in zig.

Hmm, I see. I’ll try that, thanks.