Open japplegame opened 3 years ago
This isn't optimized out, it's ignored. exportc
should error on const
. You should be using let
.
No, const
should work too.
@hlaaftana, look in the corresponding thread: https://forum.nim-lang.org/t/7763
let
does not guarantee that the initializing value will be evaluated at compile time and can be successfully placed in the`rodata ' section.
If exportc
should work for const
then I would say codegenDecl
should as well. Would probably solve my gripes with https://github.com/nim-lang/Nim/issues/17497
Adding on, if exportc
should work on consts, then should we also be able to take the addr
of a const, or at least an exported const? If so this is related to this RFC: https://github.com/nim-lang/RFCs/issues/257
The compiler must never optimize out constants marked with the
expotrc
pragma. For example:Expected C output:
Current output: Nothing (optimized out)