How to specify output type in MATLAB when using calllib

183 views Asked by At

Can I specify the output type when using calllib? My problem is MATLAB is automatically converting my output to a double even though I need an int64 and am losing needed precision.

Example

I have the following function defined in my_header.h

__int64 my_function(int arg1);

I can call the function like this:

loadlibrary('my_library', 'my_header.h')
output = calllib('my_library', 'my_function', arg1)

But then output is a double and I am losing needed precision.

What I tried

output = int64(calllib('my_library', 'my_function', arg1))

as well as

output = zeros(1, 'int64')
output(1) = calllib('my_library', 'my_function', arg1)

but these just convert my double to int64 after it has already lost the needed precision.

0

There are 0 answers