(Enhancement Request) generated code for the "arguments...end" default argument syntax in matlab coder
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
cui,xingxing
el 14 de Feb. de 2023
Respondida: Denis Gurchenkov
el 20 de Sept. de 2023
It is well known that the 'arguments' default argument syntax is very easy to use and read in MATLAB functions.In the latest version of MATLAB 2022b, C/C++ code generation for "arguments" is now supported, and according to the documentation, the entry-point function default arguments are embedded in hard-coded form.
In such situations, the default values of these optional arguments are hard-coded in the generated code and these arguments do not appear in the generated code interface.
This leads to a usability problem, if I need to make changes to the default argument values in the generated C++ code, I have difficulty in finding the location of the default arguments. Because the generated C++ code is intended for use by third parties, the default parameters should be given some flexibility to allow third party users to modify the default parameter values of the C++ function parameters.
Example:
MATLAB Code for code generation,
codegen -config:lib -c useDefaults_2 -args 0 -report
function out = useDefaults_2(a,b,c)
arguments
a (1,1) double
b (1,1) double = 5
c (1,1) double = 7
end
out = a + b + c;
end
expected:
generate a test.h and test.cpp.
test.h
double useDefaults_2(double a,double b=5,double c=7);
test.cpp
double useDefaults_2(double a,double b,double c)
{
return a+b+c;
}
instead of:
double useDefaults_2(double a)
{
return (a + 5.0) + 7.0;
}
It would be nice if in the future a soft-coded form of embedding for entry function parameters could be provided! This is because it is more in line with the Default arguments form of the C++ language itself, which is intuitive to us and easy to port to be used by others.
2 comentarios
John D'Errico
el 19 de Feb. de 2023
Please don't flag an answer as not helpful like that. I removed the flag. Perhaps you think Answers is tecnical support. It is not that. Answers is completely volunteer run. Even the rare user with the tag STAFF on their name is often answering questions by their own choice.
Your question seems to reduce to a suggestion for the software, essentially a feature request, and not a question about MATLAB at all. Steve told you to post enhancement/feature requests to the proper place. That proper place is NOT Answers.
Respuesta aceptada
Denis Gurchenkov
el 20 de Sept. de 2023
Hi CUI, just to follow up, yes this is an enhancement that is being considered for a future release. Thanks for your input!
0 comentarios
Más respuestas (1)
Steven Lord
el 14 de Feb. de 2023
Please send this enhancement request to Technical Support directly using the Contact Support link under the Get Support heading at the end of this page.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!