Simulink에서 C 함수에 구조체를 제공하려고합니다. 내 단계까지가 : Simulink에서 배열과 함께 사용자 정의 C 코드 함수에 구조를주는 방법은 무엇입니까?
- 구성에서
.h
&.c
는 사용자 지정 코드를 매개 변수 포함되어 있습니다. 내 MATLAB 함수에서 이제typedef struct mystruct { int m; int *i; double *x;}mystruct
시뮬링크에서 : 나는이 코드를 실행하면
function y = fcn(u)%#codegen 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;
내가 있음을 나타냅니다 코드 생성에서 긴 오류가 내 헤더는 구조 defind있다 그것은 C 코드로 컴파일 될 수 없습니다. 오류 : 나는 두 변수 i
및 포인터로 x
를 선언하는 경우
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 '*'
....
에만이 발생합니다. 머리글에서 스칼라로 선언하고 MATLAB 함수를 사용하면 작동합니다. 누구든지 내가 뭘 잘못하고 있는지 알아?
, 하나는 그것이 '정의 코드'섹션에 포함되어 있지 않은 경우 'HeaderFile'에 그것을 deklare 할 필요가있다. 그러나 나는 그것을 시도했다. 그리고 그것은 여전히 효과가 없다. – hans