I was working with two external functions in Dymola via two DLLs. I encountered a problem which made me think about how the compiler actually finds the external function. So the functions within the two different DLLs have the same name and the same set of input and output variables but were doing different tasks.
void Execute(int in_1, bool flag_in, bool* flag_out, int* out_1);
I defined them as the following in the external function interface in 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;
and the second function was called within another modelica function called testFunc2 just like above. What I observed was, since the external functions have the same names and the same set of input and output variables, in spite of the defined Library name, the compiler would mistakenly pick the wrong function from the other DLL and execute it.
I was wondering if there is a way to force the compiler to only look into a particular DLL when looking for an external function? or the external functions are not supposed to have identical names at all? Or is there a better way to introduce the DLL to Modelica?
If you really need the symbols to be named the same thing, use LoadLibrary and so on from the win32 API. Else, you should probably give the functions unique names for cross-tool and cross-platform compatibility.