フィルターのクリア

Prototype file different for 32 and 64 Matlab?

2 ビュー (過去 30 日間)
Marc
Marc 2014 年 2 月 6 日
回答済み: Marc 2014 年 2 月 6 日
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 日
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?

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by