Info

This question is locked. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

codegen convert C++ does not take 2 or 3 arguments error

조회 수: 5 (최근 30일)
멋진남자
멋진남자 2023년 9월 14일
Locked: Rena Berman 2024년 8월 27일
I generate C++ code completed via matlab coder but encounter error below.
I example matlab coder makes function below
void w**(double ***, double ***, coder::array<double, 1U> &w)
What is "coder::array<double, 1U> &w"?
Why there are arguments one more?
w** function have 2 argument before.
and How I get return value from void function?
[error messages]
Severity Code Description
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Error C2660 'w**': function does not take 2 arguments
Error C2660 'w****': function does not take 3 arguments
Error C2660 'w****': function does not take 2 arguments
  댓글 수: 2
Walter Roberson
Walter Roberson 2023년 9월 14일
My speculation is that the final argument would be the location to assign the output result to.
Rena Berman
Rena Berman 2024년 8월 27일

(Answers Dev) Restored edit

답변 (1개)

Matan Silver
Matan Silver 2023년 9월 14일
Hello,
Walter is correct: If you are generating code for a MATLAB function with an output, there are some scenarios in which that will become a "pass by reference" argument that represents the output of the function.
For struct arguments (which it does not look like applies in this case), you can use the PassStructByReference config parameter to influence this behavior for both entrypoint inputs and outputs: https://www.mathworks.com/help/coder/ug/pass-structure-arguments-by-reference-or-value.html#PassStructureArgumentsByReferenceOrByValueExample-5.
The "coder::array" means that particular input (or output) is a dynamically allocated array. To see more information about how to use "coder::array", you can see this doc page:
The page above also contains an example showing how you can pass a result argument by reference to store the output of the entrypoint.
There are a number of things you can do to influence the generation of dynamically allocated arrays. You could generate C instead of C++, in which case we will generate "emxArray"-style variable sized arrays: https://www.mathworks.com/help/coder/ug/use-c-arrays-in-the-generated-function-interfaces.html. You can also generate "coder::array"-style dynamically allocated arrays with C++ using the DynamicMemoryAllocationInterface parameter on the config: https://www.mathworks.com/help/coder/ref/coder.codeconfig.html#mw_3fc64d5b-5aa4-4a11-bf6b-10e138b71948. Other factors like whether the array is fixed or variable sized, if it has an upper bound on the size, etc., can change the representation of the array in generated code.
Feel free to reply if you have any further questions!
Matan

This question is locked.

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by