diff options
Diffstat (limited to 'tests/cpp')
-rw-r--r-- | tests/cpp/mexportc.nim | 9 | ||||
-rw-r--r-- | tests/cpp/texportc.nim | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/cpp/mexportc.nim b/tests/cpp/mexportc.nim new file mode 100644 index 000000000..dee51f157 --- /dev/null +++ b/tests/cpp/mexportc.nim @@ -0,0 +1,9 @@ +{.used.} # ideally, would not be needed + +var fun0 {.exportc.} = 10 +proc fun1() {.exportc.} = discard +proc fun2() {.exportc: "$1".} = discard +proc fun3() {.exportc: "fun3Bis".} = discard + +when defined cpp: + proc funx1() {.exportcpp.} = discard diff --git a/tests/cpp/texportc.nim b/tests/cpp/texportc.nim new file mode 100644 index 000000000..3a2fa8748 --- /dev/null +++ b/tests/cpp/texportc.nim @@ -0,0 +1,22 @@ +discard """ + targets: "c cpp" +""" + +var fun0 {.importc.}: int +proc fun1() {.importc.} +proc fun2() {.importc: "$1".} +proc fun3() {.importc: "fun3Bis".} + +when defined cpp: + # proc funx1() {.importcpp.} # this does not work yet + proc funx1() {.importc: "_Z5funx1v".} + +doAssert fun0 == 10 +fun1() +fun2() +fun3() + +when defined cpp: + funx1() + +import ./mexportc |