- Use the "ImportedDefine" Storage class and write a header file to define the array. You will be able to specify the header file from the Model Explorer under Code Generation options > Custom attributes. In this way, Simulink will depend on the header file to provide the definition for "CS_READ_FW_VERSION" and not generate macro directives. Inside the header file you define a constant array such as "const double CS_READ_FW_VERSION[] = {82, 86};"
- Use the "Const" Storage class instead of "Define"
Array as a #define instead of scalar
1 次查看(过去 30 天)
显示 更早的评论
Hi all
I want to use a small array as a Storage Class 'define':
However, when I use this in my model and try to generate code, it gives the following error:
So it seems I cannot use an array as a #define in code. Is this to be expected? Is there a work-around?
With kind regards,
Jonas
0 个评论
采纳的回答
Ganesh Regoti
2020-4-27
Hi Jonas,
The error thrown is an expected behaviour.
To work around this issue, you can
Hope this helps!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!