I'm trying to give a structure to a C function in Simulink. My steps so far:
- Included the .h & .c in configuration parameters custom code. My header has a structure defind:
typedef struct mystruct
{ int m;
int *i;
double *x;}mystruct
- Now in my MATLAB function under Simulink:
function y = fcn(u)
m=int32(1);
i=zeros(10,1,'int32');
x=zeros(10,1);
s.m=m;
s.i=i;
s.x=x;
coder.cstructname(s,'mystruct','extern');
D=int32(0);
D=coder.ceval('accesmystruct',coder.ref(s));
y=10;
If I run the code I get a long error from the code generation that indicates that it can't be compiled in c-code. The error is:
c2_Test2.c
c2_Test2.c(57) : error C2143: syntax error : missing ')' before '*'
c2_Test2.c(57) : error C2081: 'cs_size' : name in formal parameter list illegal
c2_Test2.c(57) : error C2143: syntax error : missing '{' before '*'
c2_Test2.c(57) : error C2059: syntax error : ')'
c2_Test2.c(60) : error C2143: syntax error : missing ')' before '*'
...
This only happens if I declare the two variables `i` and `x` as Pointers. If I declare them as scalar in the header and MATLAB function it works. Does any one see what I'm doing wrong?