How can I make a struct pointer in Matlab to pass as an argument to a function in a C dll?
14 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a C dll with a function like below:
void FunctionName ( StructName * Struct_Instance, uint8_t var1)
How can I make a struct pointer (StructName * ) in matlab to pass to this function?
I have tried doing something like this but I get errors:
S.Dev_ID = 5;
S.Fs = 3;
Sp = libpointer('c_struct',S);
0 个评论
回答(1 个)
Sugandhi
2023-2-16
Hi,
I understand that you were trying to pass struct pointer in MATLAB to a function in C DLL.
The shared library interface supports all standard scalar C types. Equivalent MATLAB types for C types can be found here- https://www.mathworks.com/help/matlab/matlab_external/passing-arguments-to-shared-library-functions.html
Some C arguments (for example, **double, or predefined structures), are different from standard MATLAB types. In these cases, either pass a standard MATLAB type and let MATLAB convert it for you or convert the data yourself using the MATLAB functions libstruct and libpointer.
For more information on manually converting data passed to functions, see the following link:
To Convert MATLAB structure to C style structure for use with shared C library, you can try using libstruct function.
For more information on libstruct and libpointer functions kindly go through following links –
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call C from MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!