Azzera filtri
Azzera filtri

Prototype file different for 32 and 64 Matlab?

2 visualizzazioni (ultimi 30 giorni)
Marc
Marc il 6 Feb 2014
Risposto: Marc il 6 Feb 2014
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

Risposte (1)

Marc
Marc il 6 Feb 2014
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?

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by