Why does using reserved keywords as Stateflow local data identifiers not cause code generation to fail with an error?
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 4 Dec 2019
Answered: MathWorks Support Team
on 4 Mar 2020
I am using a reserved keyword from the link below as a local data identifier in Stateflow:
https://www.mathworks.com/help/ecoder/ug/reserved-keywords.html
Why does code generation succeed?
Accepted Answer
MathWorks Support Team
on 4 Dec 2019
There is a distinction between how Simulink identifiers interact with reserved keywords and how Stateflow local data identifiers interact with reserved keywords. If you use a reserved keyword as an identifier in Simulink, code generation will fail with an error. However, if you use a reserved keyword as an identifier for local data in Stateflow, code generation will succeed, but the keyword will not be used in the generated code (instances of the keyword will be renamed). Adding a user-specified reserved name to configset's "Reserved names" box will cause an error when it conflicts with a Simulink identifier but will only cause a rename when it conflicts with a Stateflow local data identifier.
Note that C code generation is only concerned with C reserved keywords and code generation reserved keywords. C++ reserved keywords are ignored in this situation.
As I previously mentioned, adding user-defined reserved names to the configset option will cause an error when these keywords conflict with Simulink identifiers. There is no way to cause this same behavior for Stateflow local data identifiers.
Note that there are some additional reserved keywords for Stateflow. For further details, please refer to the following documentation page:
0 Comments
More Answers (0)
See Also
Categories
Find more on Simulink Functions 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!