Matlab 2020A Matlab Coder Use C style EmxArray Bug

조회 수: 5 (최근 30일)
dober dober
dober dober 2020년 4월 10일
답변: Andy 2020년 4월 10일
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.

채택된 답변

Andy
Andy 2020년 4월 10일
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:
- 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개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by