Passing pointer argument in MATLAB to a C-DLL function foo(char**)

前端 未结 3 761
感情败类
感情败类 2020-12-10 18:20

I am writing a C-DLL to be called from MATLAB. Is it possible to call a function with const char ** parameter? e.g.

void myGetVersion( const ch         


        
3条回答
  •  无人及你
    2020-12-10 18:49

    Looking at Working with pointers, section Passing an Array of Strings in the MATLAB documentation (linked from the help page you linked in your question), it seems you need to construct a libpointer object in MATLAB, something like

    version = libpointer('stringPtrPtr',{''}); %# corrected according to Amro's comment
    calllib('yourCdll', 'myGetVersion', version)
    

    (I don't have a DLL to test this with right now, and I'm not very firm on C pointers, so no guarantee... hope this is a step in the right direction)

提交回复
热议问题