Why does using reserved keywords as Stateflow local data identifiers not cause code generation to fail with an error?

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?

 采纳的回答

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 个)

类别

帮助中心File Exchange 中查找有关 Code Generation 的更多信息

产品

版本

尚未输入任何版本。

Community Treasure Hunt

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

Start Hunting!

Translated by