actually fixes #21889 "constructor pragma doing nothing in globals" (#21897)

actually fixes #21889
This commit is contained in:
Juan M Gómez
2023-05-24 15:42:53 +01:00
committed by GitHub
parent b63b5c930e
commit c7f2541914
3 changed files with 68 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
discard """
targets: "cpp"
cmd: "nim cpp $file"
"""
{.emit:"""/*TYPESECTION*/
struct CppClass {
int x;
int y;
CppClass(int inX, int inY) {
this->x = inX;
this->y = inY;
}
//CppClass() = default;
};
""".}
type CppClass* {.importcpp.} = object
x: int32
y: int32
proc makeCppClass(x, y: int32): CppClass {.importcpp: "CppClass(@)", constructor.}
var shouldCompile = makeCppClass(1, 2)