diff options
Diffstat (limited to 'tests/dll/visibility.nim')
-rw-r--r-- | tests/dll/visibility.nim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/dll/visibility.nim b/tests/dll/visibility.nim new file mode 100644 index 000000000..ec15dad29 --- /dev/null +++ b/tests/dll/visibility.nim @@ -0,0 +1,43 @@ +discard """ + output: "" +""" + +const LibName {.used.} = + when defined(windows): + "visibility.dll" + elif defined(macosx): + "libvisibility.dylib" + else: + "libvisibility.so" + +when compileOption("app", "lib"): + var + bar {.exportc.}: int + thr {.exportc, threadvar.}: int + proc foo() {.exportc.} = discard + + var + exported {.exportc, dynlib.}: int + exported_thr {.exportc, threadvar, dynlib.}: int + proc exported_func() {.exportc, dynlib.} = discard +elif isMainModule: + import dynlib + + let handle = loadLib(LibName) + + template check(sym: untyped) = + const s = astToStr(sym) + if handle.symAddr(s) != nil: + echo s, " is exported" + template checkE(sym: untyped) = + const s = astToStr(sym) + if handle.symAddr(s) == nil: + echo s, " is not exported" + + check foo + check bar + check thr + + checkE exported + checkE exported_thr + checkE exported_func |