Matlab Coder and the uint64 size_t
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
1 Kommentar
Akzeptierte Antwort
Kaustubha Govind
am 13 Jun. 2012
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 Kommentare
Kaustubha Govind
am 14 Jun. 2012
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.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!