Matlab Coder and the uint64 size_t
조회 수: 9 (최근 30일)
이전 댓글 표시
I've been trying to write some Matlab Coder code that needs a bunch of coder.ceval calls to functions in mat.h and mex.h. I've come into a problem, however, because my 64-bit system defines the "size_t" macro as a "long unsigned int", meaning a "uint64" which is not suppoted by codegen. If I attempt to return size_t variables as int32 or uint32, I definitely get the wrong answer (specifically, that sizeof(double)=6, sizeof(char)=4, sizeof(int)=3, etc). Does this mean that the Matlab Coder flat-out does not support coder.ceval calls on 64-bit systems that define size_t as a long int? That seems fairly crippling.
채택된 답변
Kaustubha Govind
2012년 6월 13일
If you have access to the Fixed-Point Toolbox, it looks like you might be able to get around the limitation the declaring the output of the function as a fixed-point type:
y = fi(0, 0, 64, 0);
Alternatively, you could perhaps create a new "helper" C-function to cast size_t to uint32 for you and use coder.opaque to do something like this:
--- C function prototypes ----
size_t myfun(double u);
uint32_t cast_sizet_uint32(size_t);
---- Using them in MATLAB code for code-generation ---
t = coder.opaque('size_t');
t = coder.ceval('myfun', u); %call function that returns size_t
y = uint32(0);
y = coder.ceval('cast_sizet_uint32', t); %call your helper that does the cast
댓글 수: 2
Kaustubha Govind
2012년 6월 14일
Thanks for posting your observations! I would also recommend submitting this as an enhancement request to MathWorks Tech Support so that the development team is aware of the need to address this limitation.
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!