Is there a way to make nim compiler to evaluate constants from C-header files at compile time?
For example, symbols S_IFREG and S_IFDIR (from posix.nim <- sys/stat.h) used in following code snippet:
case x:
of S_IFREG: echo "file"
of S_IFDIR: echo "dir"
else: echo "other"
are resulting in error "cannot evaluate at compile time: S_IFREG" because these symbols declared as 'var' in posix.nim, when they are constants actually. What would be a nice workaround for this?
Thank you @jlp765, I know about the static, but asking about a different thing:
Is there a way in nim language to use values of S_IFREG and S_IFDIR in the 'of' clause of the 'case-of' statement? (for example, like in the post above)