Is it possible to call a function in a C++ DLL from C code?
The function is not declared extern "C"
.
An ugly platform dependent hack that only works with Visual Studio is fine.
Calling conventions should not be a major issue, but how do I deal with name mangling.?
For instance with Visual Studio, a C++ function with signature void f()
has the mangled name ?f@@YAXXZ
and that is not a legal C identifier.
(You don't need to tell me that I should declare the C++ function as extern "C"
.
I already know that. But I'm in a situation where I cannot change the C++ code.)
Wrap the offenging function in another C++ function, and declare it with extern "C"
. No need to create a special DLL for it, just include one C++ file in your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With