Ian Bell
2009-11-06 00:03:04 UTC
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
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