I have added a public-domain fast numerical solver to my computational fluid dynamics code. The solver is written in C and seems to me (as someone who went straight to C++ and therefore doesn't know much about these things) as a bit strange in places. I thought the best approach for me would be to compile the code as a dll, with a single function declared as __declspec( dllexport) to provide the input/output to the solver.
I compiled a release version of the dll and added appropriate code to my C++ project (using LoadLibrary & GetProcAddress) to access the function. It all works fine for a debug build of my project, but when I compile a release version of my project, the dll is called correctly but seems to corrupt the array that contains the solution. It is mysteriously shifted to the next array in the argument list.
I'm assuming that there is some memory corruption problem, but does anyone have any ideas what it could be?
The function declaration is:
__declspec( dllexport ) int fastlap(int *plhsSize,int *prhsSize,int *pnumSing,double *px,int *pshape,int *pdtype,int *plhsType,int *prhsType,int *plhsIndex,int *prhsIndex,double *plhsVect,double *prhsVect,double *pxf,double *pxnrm,int *pnumLev,int *pnumMom,int *pmaxItr,double *ptol,int *pjob);
The solution should be returned in the plhsVect array, but for a release version it is returned in the prhsVect array.
Just to stress again – in each instance I am using the release build of the dll.
I am using Visual C++ 6.0 on Windows 2000.
Thanks for your help.