(RunTimeDataType*) notation is a cast? pointer and -> operator for sfunction
Mostra commenti meno recenti
Hello everyone,
I need to figure out the way to read a parameter from a C mex Sfunction, so I pick up some examples. I took the sfun_runtime4.c, used in sfcndemo_runtime.mdl. that you can get from this page http://www.mathworks.nl/help/toolbox/simulink/sfg/rmvd_matlablink__638.html.
I'm studying the mdlProcessParameters method, and it is a little bit tough for me to understand this notation :
RunTimeDataType *mass = (RunTimeDataType*)((ssGetRunTimeParamInfo(S,0))->data);
reading the doc of ssGetRunTimeParamInfo http://www.mathworks.nl/help/toolbox/simulink/sfg/ssupdateruntimeparamdata.html I understood that this method is used in order to obtain the attributes of the run-time parameter specified by 0 index. This method return a pointer, which, I bet, refers to a structure, from which by using the -> operator we get the data attribute. Then I'm not sure what it is supposed to do with (RunTimeDataType*), it makes a kind of cast to convert the value in a RunTimeDataType pointer, doesn't it?
Am I right about it?
e From the same method there is this other part of code which is also tricky for me to understand, I extract a part:
real_T vol = *mxGetPr(pm)
calcMass(mass, vol);
the mxGetPr return a pointer to the first element of the real data and the with * operator we can get the value of the first value, then we call calcMass function, which has as first argument an adress (see above for mass) and a value am I right? or I just have a big mess inside my head?
thanks for reading
thanks in advance for the help
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Simulink Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!