0

Can a C dll call a C++ dll? I have a pretty good idea around creating a dll and using LoadLibraryA and GetProcAddress to utilize a separate dll's functions; however, I would like to know if there are any additional concerns I should keep in mind when calling a C++ dll from a C dll.

Thanks!

PS, I've researched quite a bit, but unfortunately, most of the stuff I find is related to C# or C++. It seems like the amount of info regarding C is dwindling.

Ruben
  • 134
  • 11
  • 1
    Possible duplicate of [How do I stop name-mangling of my DLL's exported function?](https://stackoverflow.com/questions/1467144/how-do-i-stop-name-mangling-of-my-dlls-exported-function) – orhtej2 Feb 22 '18 at 21:40
  • I don't know if that works in Windows, but in Linux I've successfully loaded C++ shared libraries in C programs. I had to link against libstdc++. And the functions of the C++ library can only be called with typed that can be defined use in C, like int, char, and structs without class members. – Pablo Feb 22 '18 at 21:42
  • 3
    Unless your C++ functions are marked `extern "C"`, though, name mangling and calling convention mismatches are going to mess you up. Don't bother trying to call member functions without some assembly code to get the calling convention right. – cHao Feb 22 '18 at 22:01

0 Answers0