How to set alignment for virtual functions?

I am developing a plug-in for Win32 using mingw and cross-compiling from linux. Although my plugin was successfully loaded by the application, and I even got a com-interface from the application, I can’t call the call functions from there - the application crashed. I think this is due to incorrect alignment of the vtable interface implementation in mingw (this worked fine with MSVS).

Any help would be appreciated, thanks.

+5
source share
1 answer

VTable negotiation (in fact, the entire VTable system in general) is entirely implementation dependent. You must use the same compiler compiled with the same keys / settings in order to have a working program after binding.

For this reason, you cannot link the generated msvc binaries with the generated MinGWs. Even if you want the tables to match, the name change algorithms are different, and no one says that the two compilers will choose the same order for the individual functions inside the vtable itself.

If you need a portable interface between two compilers, you need to do this using the C interface (technically extern "C"), which has a standardized ABI.

+4
source

All Articles