32bit and 64bit Matlab mysterious discrepancy
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have come across a very strange behaviour: while calling a shared library from Matlab, it seems that I cannot pass floating point values correctly when running Matlab 64bit. Matlab 32bit works fine. Here an example to illustrate what I mean:
The shared library function:
extern __declspec(dllexport) float myTest(float b)
{
return(b); // just send back the received value
}
The prototype file:
..
fcns.name{fcnNum}='myTest';
fcns.calltype{fcnNum}='cdecl';
fcns.LHS{fcnNum}='single';
fcns.RHS{fcnNum}={'single'};
fcnNum=fcnNum+1;
..
From the Matlab command line, I type:
loadlibrary('mySharedLibrary',@sharedLibraryPrototypeFile);
calllib('mySharedLibrary','myTest',1.234)
I have 2 versions of my shared library: one compiled in 32bit, the other one compiled in 64bit.
- From Matlab32, the 32bit library is loaded and above function called. The return value is always the sent value (in above example, "1.234")
- From Matlab64, the 64bit library is loaded and above function called. The return values is never the sent value (in above example, the return value is "-3.6910e+05"). It is as if the 64bit Matlab was allergic sending float32 (single) values to my shared library. Receiveing float32 works fine (i.e. if I hard code "return(1.234f)" in my shared library).
If in above functions I replace the float argument with an integer argument (int32), both Matlab work as expected.
Does anyone have a clue what mysterious thing is going on?
Cheers
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!