Clear Filters
Clear Filters

Prototype file different for 32 and 64 Matlab?

2 views (last 30 days)
Marc
Marc on 6 Feb 2014
Answered: Marc on 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

Answers (1)

Marc
Marc on 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?

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!