Matlab 2020A Matlab Coder Use C style EmxArray Bug
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
dober dober
el 10 de Abr. de 2020
Respondida: Andy
el 10 de Abr. de 2020
Hi everyone,
I am having problems with the new MATLAB Coder app. Before Matlab 2020a, if your target code was C++, variable size output format was emxArray type. Since 2020a, it has been changed to coder::array type by default. But in the link below it says that if you still want your output variables to be in C format (emxArray) while your target is C++, go to Memory Tab and change the dynamic memory allocation interface to --> Use C style EmxArray. I am doing this but it still generates coder_array.h file and all input/outputs are in coder::array (C++) format. Is it a bug? Has anyone tried this before? I would be pleased if you tell me what I am missing. Thank you.
0 comentarios
Respuesta aceptada
Andy
el 10 de Abr. de 2020
Hi dober dober,
Unfortunatly, it looks like this is a bug in our 2020A release of MATLAB Coder.
You can work around this by doing the following:
- Convert the Project into a script as described here: https://www.mathworks.com/help///coder/ug/generate-a-matlab-script-to-build-a-project.html
- In the app toolbar, click the action menu (in the top right corner), and then select Convert to script.
- Specify the script name and click Save.
- Open the script file in the editor, you should see a piece of code that looks something like this:
%% Create configuration object of class 'coder.EmbeddedCodeConfig'.
cfg = coder.config('lib','ecoder',true);
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
cfg.DynamicMemoryAllocationInterface = 'C++'; % <---- Edit this line to say 'C'
cfg.TargetLang = 'C++';
cfg.GenCodeOnly = true;
cfg.TargetLangStandard = 'C++03 (ISO)';
- Edit the line that says "cfg.DynamicMemoryAllocationInterface = 'C++';" to say "cfg.DynamicMemoryAllocationInterface = 'C';
- Move this line so that it is after the line "cfg.TargetLang = 'C++';" The final result should look something like this:
%% Create configuration object of class 'coder.EmbeddedCodeConfig'.
cfg = coder.config('lib','ecoder',true);
cfg.GenerateReport = true;
cfg.ReportPotentialDifferences = false;
cfg.TargetLang = 'C++'; % <---- Swap these two lines
cfg.DynamicMemoryAllocationInterface = 'C'; % <----
cfg.GenCodeOnly = true;
cfg.TargetLangStandard = 'C++03 (ISO)';
The bug seems the be the cfg.TargetLang = 'C++' will overwrite the configuration option cfg.DynamicMemoryAllocationInterface with its default value (e.g. C++).
I apoligize for the inconvenience. In future versions this should be resolved and we'll look into fixing this in an update.
Thanks for pointing this out,
-Andy
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!