Skip to content
New issue

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 does not work with C++ free functions (works with C++ methods) and dynamic linking #19054

Open
risuwwv opened this issue Oct 26, 2021 · 0 comments

Comments

@risuwwv
Copy link

risuwwv commented Oct 26, 2021

Example

// test.cpp
// compiled with `g++ -o test.dll -shared test.cpp`
__declspec(dllexport) int addTwoIntegers(int a, int b)
{
  return a + b;
}
proc addTwoIntegers(a, b: cint): cint {.importcpp, dynlib: "test2.dll".}
echo addTwoIntegers(3, 7)

Current Output

# nim cpp interop2.nim
nimcache\interop2_d\@minterop2.nim.cpp: In function 'void NimMainModule()':
nimcache\interop2_d\@minterop2.nim.cpp:147:29: error: request for member 'Dl_436207617_' in '3', which is of non-class type 'int'
  147 |         int T2_ = ((int) 3).Dl_436207617_(((int) 7));
      |                             ^~~~~~~~~~~~~

Expected Output

Should compile as the same code works if C is used instead of C++.

Additional Information

$ nim -v
Nim Compiler Version 1.6.0 [Windows: amd64]
Compiled at 2021-10-19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant