Hi guys,
In my understanding, export is used to expose a Zig function to the c/c++ code, this works fine in case of executable but in case of a dll the export keyword will also export the function to the dll. This may not be what wanted in some scenario. For example,
const std = @import("std");
const win = std.os.windows;
const reason = enum(u8) {
DLL_PROCESS_DETACH = 0,
DLL_PROCESS_ATTACH = 1,
DLL_THREAD_ATTACH = 2,
DLL_THREAD_DETACH = 3,
};
// the mingW DllMainCRTStartup
extern "C" fn DllMainCRTStartup(inst: win.HINSTANCE, dllreason: win.DWORD, reserved: win.LPVOID) callconv(.c) win.BOOL;
pub export fn _DllMainCRTStartup(inst: win.HINSTANCE, dllreason: win.DWORD, reserved: win.LPVOID) callconv(.c) win.BOOL {
return DllMainCRTStartup(inst, dllreason, reserved);
}
// export to be called by mingW DllMainCRTStartup
pub export fn DllMain(_: win.HINSTANCE, _: win.DWORD, _: win.LPVOID) callconv(.winapi) win.BOOL {
return .TRUE;
}
DllMain is exported to the final dll, which is not what wanted.