Add example: calling overloaded C++ function (int and const char) from Rust#27
Add example: calling overloaded C++ function (int and const char) from Rust#27yrevash9182 wants to merge 11 commits intorustfoundation:mainfrom
Conversation
|
Hi @teor2345, I've updated my PR moved everything into an overloaded-greet subdirectory to match the new examples structure, added a test, and fixed the clippy/rustfmt warnings. Let me know if anything else needs changing! |
teor2345
left a comment
There was a problem hiding this comment.
Thanks for this, just checking some of the types match
teor2345
left a comment
There was a problem hiding this comment.
This is good to merge after we fix up the documentation.
examples/README.md
Outdated
|
|
||
| # Examples | ||
|
|
||
| ## Calling Overloaded C++ from Rust |
There was a problem hiding this comment.
I'd like to keep this file readable for people adding new examples, so I don't want to add anything here yet. Adding lots of text to the same file in different PRs can also cause merge conflicts.
Please move this to the README file in the example directory, or delete it.
|
@teor2345 I have reverted the .gitignore change and moved the overloading description out of the shared README into examples/overloaded-greet/README.md |
teor2345
left a comment
There was a problem hiding this comment.
I'm sorry, I still see an extra blank line in examples/README.md, and a deleted blank line in .gitignore.
You can reset the files to their original contents using these git commands:
git checkout main examples/README.md .gitignore
git commit|
@teor2345 i have restored .gitignore and readme for match the upstream |
|
Hey @teor2345 , as we’re approaching the final days of Outreachy, I wanted to follow up regarding my contribution. Since this needs to be merged to be counted, I’ve completed all the requested changes. Could you please take a look and let me know if we can move forward with merging this? Thanks! |
A small example showing how to call an overloaded C++ function from Rust using extern "C" wrapper functions. The C++ side has two overloads of greet() — one taking int and one taking const char*. Since Rust doesn't support function overloading, each overload is wrapped with a unique name (greet_number, greet_name) using extern "C", and called from Rust via FFI. Built using the cc crate with a build.rs script.
@teor2345