Question for Windows Programmers

I’ve got an application (ColdFusion 8) that was (I believe) compiled with Microsoft Visual Studio. You can configure this application to load third-party DLLs to extend its functionality. When the application calls a specific function within the DLL it passes along a reference to an object (C++) in memory and the DLL is suppose to then utilize the methods in the passed object to talk back to the main application.

I have written a DLL for this application.

If I compile it in MinGW and load it into the application, the application calls the DLL function just fine. I have confirmed this by having the function create and write to a little log file letting me know every time the function is called. However, any attempt to access the passed object’s methods results in, essentially, a crash.

If I take THE VERY SAME CODE and compile it with Visual Studio Express (which is free), the DLL is able to call methods of the passed object without any problem.

Now I get that mixing compilers can lead to problems and what’s going on here probably has something to do with stack alignment or differences between how objects are passed to functions between the compiles, but surely there’s a way to make the MinGW compiled DLL handle the passed object like Visual Studio. Perhaps some switch I need to apply when I compile the DLL?

Is anyone aware of any way to do this? Or at least a link to a proper primer explaining why it’s not possible. About all I’ve found off Google are forum posts by nubs like me being told by others to not mix compilers. At the very least I want some dirty details.

2 thoughts on “Question for Windows Programmers

Leave a reply to Johannes Cancel reply