To give a little example of my problem:
I have following function in my shared library:
extern __declspec(dllexport) int setVelocity(int client,int handle,float velocity,int mode);
In my prototype file I have following:
fcns.name{fcnNum}='setVelocity'; fcns.calltype{fcnNum}='cdecl'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'int32', 'int32', 'single', 'int32'};
In a M file, that loads the shared library, I also have this function, which calls the shared library:
function [rtn ]= setVelocity(obj,client,handle,velocity,mode)
handle_ = int32(handle);
velocity_ = single(velocity);
mode_ = int32(mode);
[rtn ] = calllib(obj.libName,'setVelocity',client,handle_,velocity_,mode_);
end
While calling setVelocity works perfectly fine with the 32bit library and the 32bit Matlab, it doesn't work correctly with the 64bit library and the 64bit Matlab: the float value is "magically" turned into -2.0f or 0.0f when the library function is called. How can that be? Am I missing something important?