필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

emlc C code generation error "Unable to apply the reference parameter optimization"

조회 수: 1 (최근 30일)
John
John 2013년 4월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a code base with several M functions I am converting to be included into an existing C code base. I am trying to limit the input by value overhead of large structures so created a glob structure. Some data is input, some output, some are persistent.
I have 2 functions which use this same global structure.
function [glob] = foo_gen
Data = struct('Input',zeros(8,1),'Output',zeros(8,1),'State',zeros(1));
eml.cstructname(Data,'DataStruct_t');
glob = struct('AllData',repmat(Data,3,1));
eml.cstructname(glob,'GlobalStruct_t');
end
function [glob] = foo(glob)
eml.cstructname(glob,'GlobalStruct_t');
eml.cstructname(glob.AllData(1),'DataStruct_t');
glob.AllData(1).Output = glob.AllData(1).Input;
end
I have many difficulties with getting this compile. Sometimes, it errors out that the tpyes do not match or is reused when the foo and foo_gen do not match exactly. It errors out if the foo function encapsulates the eml.cstructnames in an if ~isempty(eml.target) block.
I am using a multiple-entry point emlc invocation: emlc -c -s rtw_config -d ..\M_Code_Release foo -eg {glob} foo_gen
What does the error message "Unable to apply the reference parameter optimization to 'glob' of function 'foo'" mean and how do I fix it. The suggestion is to rewrite the code to not have outputs and inputs with matching names but my real code would be unworkable like that.

답변 (1개)

Fred Smith
Fred Smith 2013년 4월 15일
This sounds like a bug. What version of MATLAB are you using?
Your example worked in the latest version of MATLAB after upgrading to the latest syntax:
.m:
function [glob] = foo(glob)
coder.cstructname(glob,'GlobalStruct_t');
coder.cstructname(glob.AllData(1),'DataStruct_t');
glob.AllData(1).Output = glob.AllData(1).Input;
end
foo_gen.m:
function [glob] = foo_gen
Data = struct('Input',zeros(8,1),'Output',zeros(8,1),'State',zeros(1));
coder.cstructname(Data,'DataStruct_t');
glob = struct('AllData',repmat(Data,3,1));
coder.cstructname(glob,'GlobalStruct_t');
end
doit.m:
glob = foo_gen;
codegen -c -config:lib -d ..\M_Code_Release foo -args {glob} foo_gen

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by