Opened 8 years ago
Closed 8 years ago
#4009 closed defect (fixed)
Array types defined with type are not dealt with correctly in external functions
Reported by: | Francesco Casella | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 1.11.0 |
Component: | Run-time | Version: | |
Keywords: | Cc: | gianluca.bardaro@…, luca.bascetta@… |
Description
Consider this simple test case
model M type T = Real [3]; Real x; function f input Real x; input T t_in; output Real y; external "C"; annotation(Include = " #include <stddef.h> double f(double x, const double *t_in, size_t t_in_size) { return x + t_in[0] + t_in[1] + t_in[2]; } "); end f; equation x = f(time,{1, 2, 3}); end M;
When compiling it, you get this error:
M_functions.c:17:12: error: too few arguments to function 'f' _y_ext = f(_x_ext, (const double*) _t_in_c89);
Since T is actually an array, according to the Modelica Specification, section 12.9, the above function call should have an extra argument of type size_t containing the size of the array. Apparently, the type declaration masks this information in the code generation.
Attachments (1)
Change History (5)
by , 8 years ago
comment:1 by , 8 years ago
Seems to be InstUtil.instExtMakeExternaldecl
that does not consider arrays. It needs to be passed the type signature of the function in order to know how many dimensions the array has.
comment:2 by , 8 years ago
Seems to not be as easy to fix as I would like. You also need to consider protected variables for the implicit external call (which the current implementation does not consider).
comment:3 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
Test script to reproduce the problem