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
========================================================================

Antworten (1)

Jacob Mathew
Jacob Mathew am 2 Sep. 2026 um 9:20

0 Stimmen

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:

Kategorien

Mehr zu Simulink Coder finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024b

Gefragt:

am 28 Aug. 2026 um 4:43

Beantwortet:

am 2 Sep. 2026 um 9:20

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by