Prototype file different for 32 and 64 Matlab?

Hello,
I generated a prototype file in order to access functions in a shared library. I generated the prototype file on a Matlab 32bit system, but am also using it with Matlab 64bit systems.
On Matlab 64bit systems, functions involving arguments of type float will behave strangely (i.e. a different value will be handed over to the shared library). Is that normal?
Do I need different prototype files on Matlab 64 than on Matlab 32?
Thanks for any insight

답변 (1개)

Marc
Marc 2014년 2월 6일

0 개 추천

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?

카테고리

도움말 센터File Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

질문:

2014년 2월 6일

답변:

2014년 2월 6일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by