When I follow this topic "Call Custom C/C++ Code from the Generated Code" to generate my own external/legacy C++ code, coder.varsize('myvar') does not work. How do I declare 'myvar' to be a variable-length character vector or a variable-length scalar string? function out = useImageAndString(imagePathList,image1)
imagePathList (1,1) string = "input.txt"
image1 (100,200) uint8 = zeros(100,200,'uint8')
if ~coder.target("MATLAB")
out = zeros(size(image1),"uint8");
coder.cinclude('test1.h');
coder.updateBuildInfo('addSourceFiles', 'test1.cpp');
imgPath = char(imagePathList);
coder.varsize('imgPath');
coder.ceval('getImageNames',coder.rref(imgPath));
coder.ceval('getImage', coder.rref(image1),coder.wref(out));
my test1.h like this:
void getImageNames(const char* imgList);
void getImage(const unsigned char inImage[20000],unsigned char outImage[20000]);
The input parameter `imgList` to the getImageNames function is a variable-length character vector or a variable-length scalar string. I tried coder.varsize to declare it, but the generated C++ code still fixes the length size with my example, how can I fix it?
codegen -config:mex useImageAndString -args {"111.txt",ones(100,200,"uint8")} -launchreport -lang:c++
For example, the example command above generates C++ code that fixes imagePathList argument the length to 7
run in R2022b