【发布时间】:2015-11-18 19:08:22
【问题描述】:
我在 Dymola 中通过两个 DLL 处理两个外部函数。我遇到了一个问题,让我思考编译器实际上是如何找到外部函数的。因此,两个不同 DLL 中的函数具有相同的名称和相同的输入和输出变量集,但执行不同的任务。
void Execute(int in_1, bool flag_in, bool* flag_out, int* out_1);
我在Modelica的外部函数接口中定义如下:
function testFunc1
input Integer in_1;
input Boolean flag_in;
output Boolean flag_out;
output Integer[5] out_1;
external C Execute(int in_1, bool flag_in, bool* flag_out, int* out_1)
annotation(Library = "DLL1");
end testFunc1;
第二个函数在另一个名为 testFunc2 的 modelica 函数中被调用,就像上面一样。 我观察到的是,由于外部函数具有相同的名称和相同的输入和输出变量集,尽管定义了库名称,编译器会错误地从另一个 DLL 中选择错误的函数并执行它。
我想知道是否有办法强制编译器在查找外部函数时只查看特定的 DLL?或者外部函数根本不应该具有相同的名称?或者有没有更好的方法将 DLL 引入 Modelica?
【问题讨论】:
标签: c function external modelica dymola