-
Notifications
You must be signed in to change notification settings - Fork 14
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
C++ interop #12
Comments
@mratsim author probably meant that both D (with this special compiler) and Nim can both use C++ directly |
comment from @Laeeth which I'm moving to here:
|
PR's welcome to update this section (especially with the latest D work on the answer is a lot more complicated and more nuanced than with C #30. For example you can do the same as for #30 but with C++ ( # search for other such examples in Nim repo
proc make_unique_str(a: cstring): stdUniquePtr[stdString] {.importcpp: "std::make_unique<std::string>(#)", header: "<string>".}
proc foobar(a: cint) {.importcpp.} # untested but something like that works; at very least by providing mangled name
{.emit:"""
#include <stdio.h>
template<typename T> void foobar(T a){
printf("in foobar\n");
}
template void foobar<int>(int a); // explicit instantiation required otherwise link error
""".} however this won't work with templates (unless explicitly instantiated); and also still requires defining headers manually; this is what nimterop (and to a lesser extend the "official" relevant links |
Not sure what Calypso is but I have no problem doing C++ Cuda integration in Nim:
Example on applying element-wise operation on 2 tensors dest and src
Cuda C++ kernels
Apply the operation on a whole tensor
Apply Cuda C++ Higher order function
Generate the Nim <-> C++ bindings
Usage:
The text was updated successfully, but these errors were encountered: