我无法找到如何在我的OpenModelica项目中正确删除以下警告:
[1] 18:05:18 Translation Warning
[MyModel: 3:1-11:25]: An external declaration with a single output without explicit mapping is defined as having the output as the lhs, but language C does not support this for array variables. OpenModelica will put the output as an input (as is done when there is more than 1 output), but this is not according to the Modelica Specification. Use an explicit mapping instead of the implicit one to suppress this warning.
当 * 检查 * 我的模型(从OMEdit内部)时出现,该模型具有以下函数声明作为包的一部分
within MyPackage;
impure function MyExternalFunction "My External Function"
input Real input1 "Input 1";
input Real input2 "Input 2";
input Real input3 "Input 3";
output Real result[2] "result1, result2";
external "C" annotation(
IncludeDirectory = "modelica://MyPackage/",
Include = "#include \"my_code.c\"");
end MyExternalFunction;
实际的C代码看起来像这样
void MyExternalFunction(double input1, double input2, double input3, double* result, size_t n) {
result[0] = 1.2; // result 1
result[1] = 3.4; // result 2
n = 2;
}
我已经阅读了OpenModelica规范中的外部函数一章,但毫无用处。
代码编译并按照需要正确返回值。
我应该如何修改上面的代码来删除警告?
1条答案
按热度按时间hof1towb1#
我想应该是这样的: