I’m using translate-c to generate a zig “header” from a C .h file like so:
zig translate-c src/gfxutil/joystick.h > src/gfxutil/joystick_c.zig
The contents of joystick.h
are basically just:
#pragma once
typedef struct {
int idx;
int lx;
int ly;
int lz;
int rx;
int ry;
int rz;
unsigned int buttons;
} win32_read_result;
extern void win32_joystick_init(void);
extern win32_read_result win32_joystick_read(void);
The output zig file contains all the Zig built ins and is over 400 lines long:
pub const __builtin_bswap16 = @import("std").zig.c_builtins.__builtin_bswap16;
pub const __builtin_bswap32 = @import("std").zig.c_builtins.__builtin_bswap32;
pub const __builtin_bswap64 = @import("std").zig.c_builtins.__builtin_bswap64;
pub const __builtin_signbit = @import("std").zig.c_builtins.__builtin_signbit;
Is there a way to stop translate-c from including the builtins in output? I’d like the output to contain only my own C declarations? I’m checking these outputs into Git and it’d be nice to cut down on the # of declarations in my import zig files for both cleanliness and readability.
I first tried using @cImport but that seems to only work with system include paths and not .c/.h files in my own game projects.