Simulink Coder creates variables that are never used.

4 views (last 30 days)
Hello everybody,
When generating code for a simulink model, specially for a STATEFLOW CHART, simulink coder generates some local variabiles that are never used. These variables are declared inside functions that are part of the stateflow chart generated code:
1) These variables are present in two pieces of code: the first time they are declared is inside the function "Function for Chart '<S12>/Chart' " . In this function they are declared and used somehow. No problems in here.
/* Function for Chart: '<S12>/Chart' */
static void xxx_ERT_chartstep_c2_LCL_ERT(void)
{
/* local block i/o variables */
real32_T rtb_xxx_B1;
(...)
real32_T rtb_Switch;
real32_T rtb_Switch_jyyit;
real32_T rtb_VariantMergeForOutportLCLTG;
real32_T rtb_VariantMergeForOutpor_ikim0;
real32_T rtb_VariantMergeForOutpor_jv45a;
real32_T rtb_VariantMergeForOutpor_jnbnl;
real32_T rtb_VariantMergeForOutportECO_K;
(...)
}
So far so good. But now for the second function created by the coder * " Output and update for function-call system: '<S12>/Chart' " * these local variables are NEVER used inside the function! They are just declared again, for nothing.
/* Output and update for function-call system: '<S12>/Chart' */
void xxx_ERT_Chart(int32_T controlPortIdx)
{
/* local block i/o variables */
// real32_T rtb_Switch;
// real32_T rtb_Switch_jyyit;
// real32_T rtb_VariantMergeForOutportLCLTG;
// real32_T rtb_VariantMergeForOutpor_ikim0;
// real32_T rtb_VariantMergeForOutpor_jv45a;
// real32_T rtb_VariantMergeForOutpor_jnbnl;
// real32_T rtb_VariantMergeForOutportECO_K;
// uint32_T rtb_BitwiseOperator_fpzv4;
// uint32_T rtb_BitwiseOperator_hogum;
// uint32_T rtb_VariantMergeForOutportLCL_C;
// uint32_T rtb_VariantMergeForOutpor_gxh3b;
// uint32_T rtb_VariantMergeForOutpor_pmc4r;
// uint32_T rtb_VariantMergeForOutpor_h4rf5;
// uint8_T rtb_Switch_i4zmq;
int8_T rtb_inputevents[3];
The "// commented" variables are the ones that are created inside this "output and update" function, but they are never used inside THIS funcion. However, these were declared AND used before, locally inside the "Function for Chart '<S12>/Chart'.
Its not a big deal because the code works as it should. The problem is that when compiling, the compiler generates a warn, saying that these variables are never used.
Does anyone knows how to "fix" it, without changing manually the generated ERT code ?
Regards,
Piero Costa

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!