Is there any constant variable or proc
that allows to access the compiler version as a string or number?
How to obtain the nim compiler version programmatically ?
The version can be obtained as a string via system.NimVersion
(remember that system
is implicitly imported):
echo NimVersion # 0.18.0
You can also access its component parts (MAJOR.MINOR.PATCH) as numbers like so:
echo NimMajor # 0
echo NimMinor # 18
echo NimPatch # 0
This makes checking versions for compatibility very easy when combined with tuples:
when (NimMajor, NimMinor, NimPatch) >= (0, 19, 0):
echo "we're on at least Nim v0.19.0"
© 2022 - 2024 — McMap. All rights reserved.