mimportc.nim 505 B

123456789101112131415161718192021222324252627
  1. #[
  2. this test will grow with more importc+importcpp tests; see driver in trunner.nim
  3. ]#
  4. {.emit:"""
  5. struct A {
  6. static int fun0(int a){
  7. return a;
  8. }
  9. static int& fun1(int& a){
  10. return a;
  11. }
  12. };
  13. """.}
  14. proc fun0*(a: cint): int {.importcpp:"A::$1(@)".}
  15. proc fun1*(a: var cint): var int {.importcpp:"A::$1(@)".} =
  16. ## some comment; this test is for #14314
  17. runnableExamples: discard
  18. proc main()=
  19. var a = 10.cint
  20. doAssert fun0(a) == a
  21. doAssert fun1(a).addr == a.addr
  22. echo "witness"
  23. main()