How do I use SS_RTW_STORAGE_CUSTOM?
Show older comments
Hello!!!
I want to create a variant, define in CodeGen .c file. I am using s-func, find SS_RTW_STORAGE_CUSTOM is defined in C:\Program Files\MATLAB\R2024b\simulink\include\rtw_storage.h.
I use it in C code for s-func: ssSetDWorkRTWStorageClass(S, 0, SS_RTW_STORAGE_CUSTOM). But CodeGenerator tells "Unknown error processing storage class: Custom".
Do I miss something to setup custome storage? I certainly want a custom storage like "MEM_CUSTOM_CAL", it works if I use a Simulink.Parameter variant. but how can I use it in s-func by ssSetDWorkxxxxxx or smiliar function.
s-func C code:
ssSetNumDWork(S,1);
ssSetDWorkWidth(S,0,1);
ssSetDWorkDataType(S,0, dataType);
ssSetDWorkName(S,0,dworkName);
ssSetDWorkUsedAsDState(S,0,SS_DWORK_USED_AS_DSTATE);
ssSetDWorkRTWIdentifier(S, 0, dworkName);
ssSetDWorkRTWTypeQualifier(S, 0, "");
ssSetDWorkRTWStorageClass(S, 0, SS_RTW_STORAGE_CUSTOM);
===================================================================
TLC of s-function
%function Outputs(block, system) Output
%openfile buf
/* ===== TLC DWork TEST ===== */
/* DWork information */
%if EXISTS(block.DWork)
%<LibBlockDWork(block.DWork, "", "", "0")> = 0;
%endif
%closefile buf
%<buf>
%endfunction
========================================================================
Answers (1)
Jacob Mathew
on 2 Sep 2026 at 9:20
Hey Callum,
The documented ssRTWStorageType values accepted by ssSetDWorkRTWStorageClass are only:
typedef enum {
SS_RTW_STORAGE_AUTO = 0,
SS_RTW_STORAGE_EXPORTED_GLOBAL,
SS_RTW_STORAGE_IMPORTED_EXTERN,
SS_RTW_STORAGE_IMPORTED_EXTERN_POINTER
} ssRTWStorageType
When you pass the SS_RTW_STORAGE_CUSTOM to it, this causes the downstream code generation to throw the error "Unknown error processing storage class: Custom". Reference the following MATLAB documentation for more information:
Categories
Find more on Simulink Coder 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!