I'm looking for something similar to python's sys.platform, which returns 'linux', 'windows', etc, or even better, something like python's platform module which gives you the operating system, distribution, release version, etc.
when defined windows:
echo "I'm on Windows!"
elif defined linux:
echo "I'm on Linux!"
else:
echo "I'm on some other platform!"
when defined x86:
echo "x86 specific code!"
elif defined amd64:
echo "amd64 specific code!"
else:
echo "generic code!"
when (NimMajor,NimMinor,NimPatch) > (0,10,2):
echo "Such a modern Nim version!"
echo "OS: ", hostOS, ", CPU: ", hostCPU, ", cpuEndian: ", cpuEndian, ", NimVersion: ", NimVersion
This prints on my system:
I'm on Linux!
amd64 specific code!
Such a modern Nim version!
OS: linux, CPU: amd64, cpuEndian: littleEndian, NimVersion: 0.10.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With