Hi!
In C if I wanted to define functions/structs/etc. that have different implementations depending on what operating system the build was targeting I could do something like this
/// my_code.h
int do_platform_specific_function();
/// my_code_win32.c
#if defined(_WIN32)
#include "my_code.h"
#include <Windows.h>
// only compiles on windows
int do_platform_specific_function() { ... }
#endif
/// main.c
#include "my_code.h"
int main() {
// calls based on OS-specific C file got compiled
int value = do_platform_specific_function();
...
}
where do_platform_specific_function() can have platform-specific implementations and the code that uses it doesn't have to care about the details. Also with the benefit that code which links to OS-specific libraries won't get compiled on other OSes (and thus not causing linking errors). How can I achieve something similar in Zig? I couldn't find much clear information online about this.