Nim
Nim copied to clipboard
Document isMainModule and appType for libraries
# foo.nim
when isMainModule: echo "hi from foo"
# bar.nim
import dynlib
when isMainModule: echo "hi from bar"
doAssert(not loadLib("./libfoo.so").isNil)
nim c --app:lib foo
nim c -r bar
Output:
hi from bar
hi from foo
Expected output:
hi from bar
Note: I'm not sure it's an issue, but I'm getting a lot of questions about it in nimpy.
Works as expected. We can improve the documentation and mention appType == "lib" and similar.
@Araq
Can you explain how to use appType == "lib" to make the example work?
@xflywind
when isMainModule and appType != "lib" I guess