S-Function parameter generates unnecessary array
Show older comments
Hi,
I am facing a problem with the c code generation of an S-Function:
I generated the S-Function with the legacy code tool. The only use of the S-Function is to insert a function call in the generated c-code. But as I need several calls to different functions, I am passing the respective name of the function as parameter event to the S-Function:

In the tlc file of the S-Function the Outputs function is defined like this to generated the function call:
%function Outputs(block, system) Output
%%
%assign event = LibBlockParameterString(P1)
%assign y1_ptr = LibBlockOutputSignalAddr(0, "", "", 0)
%%
%<event>( %<y1_ptr> );
%%
%endfunction
This way in the generated code appears always the function call passed as event e.g. dem_Call_Function1(dem_event_prefail);
Unfortuanetly also is generated for each call a uint16_t array of the size of the function call name which is not used at all, but just occupies space.
e.g. for dem_CallFunction1 there is generated:
uint16_t SFunction[18];
The array is initialized in the generated _data.c file like this:
{ 100U, 101U, 109U, 95U, 67U, 97U, 108U, 108U, 95U, 70U, 117U, 110U, 99U, 116U,
105U, 111U, 110U, 49U }
The question is now how could I avoid, that these useless arrays are getting generated?
1 Comment
Michael Frena
on 13 Feb 2020
Answers (0)
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!