We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importcpp
Version 2 of #5140.
Consider the following:
{.emit:""" #import <cassert> class C { public: int d; C(): d(1) { } C& operator=(const C other) { assert(d == 1); d = other.d; return *this; } }; """.} type C* {.final, importc: "C".} = object proc newC*(): C {.importcpp: "C".} proc mkC*(): C = result = newC() discard mkC()
The assertion fails because Nim generates a memset for mkC's result:
mkC
N_NIMCALL(C, mkc_x4uLyT9aRomf9cN9bUnV4BPJg)(void) { C result0; nimfr("mkC", "test.nim") memset((void*)(&result0), 0, sizeof(result0)); nimln(24, "test.nim"); result0 = C(); popFrame(); return result0; }
The text was updated successfully, but these errors were encountered:
But you need to use importcpp to import the type and then the problem disappears.
type
Sorry, something went wrong.
I see, can't believe I missed this. Thanks!
No branches or pull requests
Version 2 of #5140.
Consider the following:
The assertion fails because Nim generates a memset for
mkC
's result:The text was updated successfully, but these errors were encountered: