How to obtain the nim compiler version programmatically ?
Asked Answered
A

1

5

Is there any constant variable or proc that allows to access the compiler version as a string or number?

Accomplishment answered 9/10, 2018 at 18:9 Comment(0)
A
7

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"
Accomplishment answered 9/10, 2018 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.