Hi,
I need to wrap C constant which can be either #define or const int, it is in standard C header so in order to be portable I can't specify the value, run c2nim or assume something.
The following does work:
var FLT_MIN {. importc: "FLT_MIN" header: "<float.h>" .} : cfloat
But unfortunately, the FLT_MIN is declared as var causing a havoc in the side effect tracking we are using. The following does not seem to work:
const FLT_MIN {. importc: "FLT_MIN" header: "<float.h>" .} : cfloat
Any better ideas?
Thanks
const FLT_MIN = 1.175494350822288e-038
Float is 32 bits everywhere and IEEE too. Chances are it's portable enough. In general for these problems the best way is to have some "detect" logic with static: writeFile and staticExec which we should probably provide some helpers for.
I just checked the fenv module and it is indeed using var: https://github.com/nim-lang/Nim/blob/master/lib/pure/fenv.nim#L173.
By the way, can we rename fenv to something more searchable, it's un-googlable without theindex or knowing its name.