Skip to content
Snippets Groups Projects
Commit 0d76645a authored by Marvin Häuser's avatar Marvin Häuser
Browse files

simulator: emit channels array only when not empty

Arrays of length 0 yield implementation-defined behaviour, which causes
a compiler warning. In C, this was typically used to model
flexibly-sized array members trailing a struct. Here, length 0 actually
means it occupies no storage.

Hence, do not emit the _channels array when it would otherwise have a
length of 0.
parent 065677ee
No related branches found
No related tags found
1 merge request!477[WIP] simulation code generation fixes
......@@ -1131,7 +1131,10 @@ public class MappedSystemCTask {
//code += "ParamType arg2__req" + SCCR;
//code += "ParamType arg3__req" + SCCR;
code += "ParamType rnd__0" + SCCR;
code += "TMLChannel* _channels[" + (channels.size() + events.size() + (task.isRequested() ? 1 : 0)) + "]" + SCCR;
int num = channels.size() + events.size() + (task.isRequested() ? 1 : 0);
if (num > 0) {
code += "TMLChannel* _channels[" + num + "]" + SCCR;
}
return code;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment