I want to make a tool for a friend who is still on Windows 7. (Reads some folders/files, analyses them, prints results, done.) Yes, we all know that anything older than Windows 11 is no longer supported by Microsoft. No, he will not be upgrading his computer anytime soon, especially with the recent… events. Whatever I make, it has to run on 32-bit Win 7, otherwise it’s useless.
So far, using Zig, the default project provided by zig init doesn’t even run on his computer. Reason being that the standard library uses syscalls such as NtAlertThreadByThreadId, which was added in Win 8. In a perfect world, the standard library would first check the build’s OS version range via builtin.os.version_range.windows.isAtLeast(.win8). However, I fully understand that this would be a huge amount of work to do for every single Windows syscall everywhere, especially since you then also have to come up with workarounds for old OS versions.
So, what can I do?
It looks like to me that I am simply forced to use a different language. Well, in that case, can anyone suggest something that would work? Some old version of a C compiler+library, or maybe something else entirely. I’m using Windows 10 myself, and I have a feeling that simply getting to the point that I have anything that runs at all is gonna be really annoying…
You can patch std in your Zig installation to use Win7-compatible calls. But I’m suspecting that this could be quite a task.
Alternatively you can skip Io-interface and directly call whatever you need, but now that I think about it, you will need to avoid std.debug and std.log to not involve Io-interface.
To be honest, having Win7-compatible (or WinXP or Win95!) Io would be nice to have, but I’m suspecting that if this will happen it should not be expected to be maintained by Zig team.
Zig 0.17.0 lists Windows 10 as the minimum required version of Windows. This has been the minimum required version for at least a couple years. Here’s an issue from 2020 where Windows 7 stopped being supported.
I’m sorry for your friend, but Windows 10 has been out for over a decade. Supporting such an old system (pre-10) simply isn’t a priority for the Zig maintainers. Too much effort for too little benefit. Heck, even modern Windows isn’t in the top tier of support. Your friend may be able to run your programs if they install Linux on their machine instead, but with such an old machine there may be other difficulties.
The best bet is target the x86-windows-gnu, and use -ofmt=c to emit a piece of C codes…
Then you can use Wine (assuming that you can use Linux or WhateverBSD or at least on a virtual machine or maybe Windows Linux subsystem) to install a MinGW then compile your emitted C codes to an exe… If you can run your codes on Wine, it should work on Windows 7… Wine can even emulate all the way back to Windows XP or something…
Actually it’s real easy to patch std: Welcome to Johnny's World
There is also VxKex a tool that emulates missing API functions on Windows 7.
I haven’t tried it myself, but someone used this tool to run Cubyz on Windows 7, so I’d assume it would also work for simpler Zig programs.