The following example code:
type
MyEnum* = enum OneValue, AnotherValue, ThirdValue
proc printf(format: cstring) {.header: "<stdio.h>", importc: "printf", varargs.}
proc test() =
for f in MyEnum: echo f, " ", int(f)
for g in MyEnum: "int value %d\n".printf(g)
when isMainModule: test()
Can be compiled with the following command:
nim c --gc:none -r nogc
and will generate the following warnings:
nogc.nim(7, 25) Warning: 'f' uses GC'ed memory [GcMem]
nogc.nim(7, 36) Warning: 'int(f)' uses GC'ed memory [GcMem]
I did take a look at the compiler user guide and saw that warnings can be disabled or enabled. Can warnings be promoted to errors to prevent generation of a binary? Can this be done for all of the warnings or just specific ones?g doesn't use managed memory, neither do f nor int(f). It's passing those values to echo which calls the $ proc on them to build a string, and strings are garbage collected. The C printf version doesn't build strings, so no warning there.
Well, I'll get going parsing the compiler output.