I faced following issue with my work: having two projects: MFC .dll and MFC .exe based on same source code (except entry points of course), I observe different results produced by them when processing same data. I have checked all projects settings for both and found all project properties similar (at least those I think are important). After running several tests I learned following:
- MFC .exe produces same results on same dataset in both ‘Debug’ and ‘Release’ modes
- MFC .dll produces Different results on same dataset for ‘Debug’ and ‘Release’ modes
- .dll’s ‘Release’ results don’t match with .dll’s ‘Debug’ results nor with any of .exe’s ‘Debug’ or ‘Release’ results.
I suppose .exe works correctly just because it gives same results for both compiler configurations, but I can’t check this for sure. So, how this issure with .dll ‘Release’ configuration can be resolved? I mean, how can I force it coincide with others? What does explain such behaviour?
Edit
I guess problem occurs because I use host application written on Delphi. I even created new C++ exe to test this suggestion and saw it worked normal, without any mistakes. Only difference is that creating DLL to be used in Delphi application I marked it extern “C”, but for C++ application I wrote just extern. Details of another discussion on this topic can be found here. But if try to use DLL with only extern mark, without “C”, my Delphi application reports that function entry point couldn’t be located there… It is a big question for me now why this happens… Any ideas?
Check the values of the 8087 Control Word for each of the hosts. I’m pretty sure that the Microsoft C uses a different value to that which Delphi uses. In the more recent Delphi versions, you have functions such as Set8087CW and the wrappers like SetPrecisionMode and SetRoundMode. But you will probably want to set them specifically in your DLL, and then restore them to the original at the end of your calculation.