How to prevent simulink from generating code containing erroneous unused variables?

Simulink is generating an unused variable in the model init code for models that include a foreach loop. This is causing issues when we link using gcc, as we don't want any warnings for our compiled product. I'm not sure if we're defining the foreach logic incorrectly or if there is a setting we could tweak to fix this issue.
Has this issue been seen before and is there any known solutions for it?
variable is of the form:
int32_T ForEach_itr;

1 Comment

Inside the for-each subsystem add Signal conversion block at inports. This will avoid Matlab from generating unnecessary intialization of for-each variables.

Sign in to comment.

Answers (0)

Products

Asked:

on 5 Apr 2018

Commented:

on 3 Nov 2026 at 18:51

Community Treasure Hunt

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

Start Hunting!