diff options
author | Juan M Gómez <info@jmgomez.me> | 2023-10-08 22:51:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-08 23:51:44 +0200 |
commit | 8ac466980f7658c37b05c6ec099537ea0e459cb9 (patch) | |
tree | 9d1aaa8382b3f635bec29dc668ec43b4cae13972 /tests | |
parent | c3774c8821cc25187252491b4514235b9a8f1aac (diff) | |
download | Nim-8ac466980f7658c37b05c6ec099537ea0e459cb9.tar.gz |
marking a field with noInit allows to skip constructor initialiser (#22802)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpp/tnoinitfield.nim | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/cpp/tnoinitfield.nim b/tests/cpp/tnoinitfield.nim new file mode 100644 index 000000000..4deffece8 --- /dev/null +++ b/tests/cpp/tnoinitfield.nim @@ -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() \ No newline at end of file |