Hello. I'm currently able to hot reload c code in my engine by having my exe constantly check for any recompiled dll's in the project and then reload them. I'm wondering if I can drop in some zig code, compile it as a dll and have it also reload like I would with my C code. Is there any special flags I would pass to the zig compiler to make sure it exports functions and such for the C calling convention?
#Hot reloading zig code in my C99 engine
1 messages · Page 1 of 1 (latest)
Exporting a C function is well-supported, but it works a bit differently to normal functions. You have to write export fn foo(x: u32) u64 { ... } (or whatever), and the function foo will be exported (under that name) from the binary. This will implicitly use the C calling convention, which also limits the parameters and return type to ones that fit the C ABI (e.g. no weird-sized int types, no generic stuff). But everything should pretty much work how you expect aside from that - you can make your build.zig generate a shared library rather than an executable by using b.addSharedLibrary rather than b.addExecutable