marking a field with noInit allows to skip constructor initialiser (#22802)

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
Juan M Gómez
2023-10-08 22:51:44 +01:00
committed by GitHub
parent c3774c8821
commit 8ac466980f
5 changed files with 85 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
discard """
targets: "cpp"
cmd: "nim cpp $file"
output: '''
'''
"""
{.emit: """/*TYPESECTION*/
struct Foo {
Foo(int a){};
};
struct Boo {
Boo(int a){};
};
""".}
type
Foo {.importcpp.} = object
Boo {.importcpp, noInit.} = object
Test {.exportc.} = object
foo {.noInit.}: Foo
boo: Boo
proc makeTest(): Test {.constructor: "Test() : foo(10), boo(1)".} =
discard
proc main() =
var t = makeTest()
main()