mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* fixes #10578 * add tests * add changelog * add {.exportcpp.}
This commit is contained in:
committed by
Andreas Rumpf
parent
8397554315
commit
32769c478b
9
tests/cpp/mexportc.nim
Normal file
9
tests/cpp/mexportc.nim
Normal file
@@ -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
|
||||
22
tests/cpp/texportc.nim
Normal file
22
tests/cpp/texportc.nim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user