|
The simplest solution is to forget about the pointer and call:
[ status, changedval ] = calllib( 'MyLib', 'f1', 0 ); %matlab takes care of the pointer for you
If you want to use a pointer forget about the Ptr suffix
> p = libpointer( 'tMyEnum', 0 );
> [ status, p ] = calllib( 'MyLib', 'f1', p );
Numeric pointer types use the Ptr suffix to discriminate between scalar and matrix pointers but in general the Ptr suffix can be
dropped when a datatype is inside of a libpointer.
Phil
"Ian Bell" <ibell@instepsystems.com> wrote in message news:hcvp3o$7m1$1@fred.mathworks.com...
> 1) Assume a C header file contains the following declarations:
> typedef enum { e1, e2, e3 } MyEnum;
> __declspec( dllimport ) int f1( MyEnum* p );
>
> 2) Assume the library containing this function has been loaded into Matlab and the Matlab function 'libfunctions 'MyLib' -full'
> declares this function as:
> [int32, tMyEnumPtr] f1(tMyEnumPtr)
>
> My question is, what parameters are to be passed to 'calllib' so the C function 'f1' can be successfully called. The following
> fails:
> p = libpointer( 'tMyEnumPtr', 0 );
> [ status, p ] = calllib( 'MyLib', 'f1', p );
>
> Specifically, the above code generates the exception message:
> identifier: 'MATLAB:libpointer:InvalidType'
> message: 'Type was not found.'
> stack: [3x1 struct]
> cause: {}
>
> Similarly, replacing ''tMyEnumPtr' with 'MyEnumPtr' also causes an error. What is the correct 'callib' parameter(s)?
>
> Thanks,
>
> Ian
|