blob: ec15dad291dae5d782399e6c17b703959255b8d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
|