Zig bindings for variable float C code

I’ve been playing around around with a C library called aubio. It’s a library for analyzing audio (pitch, tempo and onset detection etc.) and modifying. I eventually want to build my own karaoke app in Zig. Based on the number of github stars, it seems like a high quality library, so I thought bindings to aubio could be useful for other users, too.
However, when attempting to write bindings, I stumbled upon the following construct:

Now I can of course mass replace the integer types and use c_int/c_char instead, and then use translate-c. However, this approach does not work for the floating point types.
Is there an idiomatic way to write bindings while making it possible to compile for different floating point sizes?

I referred to the C type equivalent table in the zig documentation.

const options = @import("aubio_options");
const smpl_t = if (options.HAVE_AUBIO_DOUBLE) f64 else f32;
const AUBIO_SMPL_FMT = if (options.HAVE_AUBIO_DOUBLE) "%lf" else "%f";
const lsmp_t = if (options.HAVE_AUBIO_DOUBLE) c_longdouble else f64;
const AUBIO_LSMP_FMT = if (options.HAVE_AUBIO_DOUBLE) "%Lf" else "%lf";
const uint_t = c_uint;
const sint_t = c_int;
const char_t = c_char;

Note that c_longdouble is a primitive type

2 Likes

I missed this point, thank you for your guidance.

Thank you very much, c_longdouble is what I was looking for.