4 ms·
You can absolutely link to all of those things if you have a compiler toolchain to do it. Can you dynamically load Qt's C++ DLLs from an arbitrary scripting lan
by matheusmoreira 4y ago
You can absolutely link to all of those things if you have a compiler toolchain to do it. Can you dynamically load Qt's C++ DLLs from an arbitrary scripting language and use them via foreign function interfaces though? I don't think so. I remember exploring even Boost Python source code and finding extern "C" deep in its bowels so I seriously doubt people are doing this.
- pjmlp 4y agoNaturally not, because CPython doesn't have a C++ FFI, which is a Python problem, not C++'s.
- matheusmoreira 4y ago> because CPython doesn't have a C++ FFI Does anything have a C++ FFI?
- pjmlp 4y agoC++ for starters (obviously),.NET via C++/CLI, D, Swift is in the process of getting one.
- matheusmoreira 4y ago> C++ for starters (obviously),.NET via C++/CLI Of course C++ compilers are capable of generating C++ ABI code. They are not foreign function interfaces, they are native. > D They have some rather interesting commentary on the matter. https://dlang.org/spec/cpp_interface.html https://dlang.org/spec/cpp_interface.html. > Being 100% compatible with C++ means more or less adding a fully functional C++ compiler front end to D. > making a D compiler with such capability unimplementable > the solutions have been: > Support the COM interface (but that only works for Windows). > Laboriously construct a C wrapper around the C++ code. > Use an automated tool such as SWIG to construct a C wrapper. > Reimplement the C++ code in the other language. > Give up. The pragmatic approach mentioned apparently consists of matching the D and C++ ABIs as much as possible just to make the problem tractable. Even after that impressive effort, the foreign interface is basic and incomplete. Special member functions like constructors and destructors are not supported, for instance. Notably, there is no exceptions support! > Swift is in the process of getting one Swift had to embed a literal C++ compiler inside itself in order to even make such a proposition viable. https://faultlore.com/blah/c-isnt-a-language/ https://faultlore.com/blah/c-isnt-a-language/ > Not even Swift has the stomach for this stuff.