I have some external functions which I want to use in Dymola.
For the most of the functions everything works fine, but if I want to return an array, I get the following error:
QUOTE
Error: return variable in external function call for function getN must be a scalar-valued temporary or output variable.
But got 'n' which is not a scalar variable.
Errors detected in functions.
Here is the code snippet of the C-Function:
CODE
void* getN(......)
{
double *n = malloc(3 * sizeof(double));
n[0] = ....
n[1] = ....
n[2] = ....
return (void *) n;
}
And here is the call in Dymola:
CODE
function getN
annotation(Library="my_lib");
input .....;
input .....;
output Real n[3];
external "C" n = getN(..........);
end getN;
I already have a workaround in which I have a function for every part of the array (e.g. getN_x, getN_y, getN_z) but the performance in this solution is very bad.
Does anyone know how to return arrays from external functions?
Thanks in advance,
el Kunzo
