how to allocate memory and access it in s-function
Show older comments
I allocated memory in sfunction code:
static void mdlStart(SimStruct *S)
{ uint8_T * temp = (uint8_T*)calloc(8, sizeof(uint8_T));
ssSetUserData(S, temp);
}
and free the memory in
static void mdlTerminate(SimStruct *S)
{
uint8_T *temp = ssGetUserData(S);
free(temp);
}
and used it in a output_wrapper function as
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
uint8_T *temp = ssGetUserData(S);
//start message
temp = (uint8_T *)Start_Message;
Msg_ID_Package[1] = temp[0];
Msg_ID_Package[0] = temp[1];
However I am getting linker error LNK2019: unresolved external symbol in the output_wrapper file.
I am not sure what I am doing wrong.
Thank you, Khalid
Answers (0)
Categories
Find more on Configure C/C++ S-Function Features in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!