what data type do i need to calllib with pointer argument char*
20 ビュー (過去 30 日間)
古いコメントを表示
Hey there! I'm using a shared library and I'm tring to call this function from it (from h file):
long PI_FUNC_DECL PI_EnumerateUSB(char* szBuffer, long iBufferSize, const char* szFilter);
So I'm making the following code:
>> szBuffer = libpointer('char');
>> iBufferSize = libpointer('int32');
>> calllib(libalias,'PI_EnumerateUSB',szBuffer,iBufferSize,'E-861');
Error using calllib
Pointer type must match data type
After some checking, the problem is without doubt the char* (szBuffer). From what I understand from Matlab Help I need it to be a char array, so what am I'm doing wrong?
p.s.
I have the problem in other functions as well that require char*
Thanks!
0 件のコメント
回答 (1 件)
Philip Borghesani
2014 年 5 月 28 日
You are over thinking this let MATLAB do the work no libpointers are needed:
[status, resultString]=calllib(libalias,'PI_EnumerateUSB',blanks(100),100,'E-861')
The code you wrote is doing the equivalent of the c code:
char *szBuffer=NULL; int* iBufferSize=NULL;
PI_EnumerateUSB(szBuffer,*iBufferSize,"E-861");
and if you were using C your program would crash...
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!