Info
此问题已关闭。 请重新打开它进行编辑或回答。
emlc C code generation error "Unable to apply the reference parameter optimization"
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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
1 个评论
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!