tnoinitfield.nim 448 B

123456789101112131415161718192021222324252627282930
  1. discard """
  2. targets: "cpp"
  3. cmd: "nim cpp $file"
  4. output: '''
  5. '''
  6. """
  7. {.emit: """/*TYPESECTION*/
  8. struct Foo {
  9. Foo(int a){};
  10. };
  11. struct Boo {
  12. Boo(int a){};
  13. };
  14. """.}
  15. type
  16. Foo {.importcpp.} = object
  17. Boo {.importcpp, noInit.} = object
  18. Test {.exportc.} = object
  19. foo {.noInit.}: Foo
  20. boo: Boo
  21. proc makeTest(): Test {.constructor: "Test() : foo(10), boo(1)".} =
  22. discard
  23. proc main() =
  24. var t = makeTest()
  25. main()