ert static function declaration when using newer versions of matlab

1 次查看(过去 30 天)
Hello, I am using a custom tlc file that was based off of ert.tlc from an older version matlab. The custom code had worked fine through multiple matlab versions and I can confirm it was ok up through version 2018b but is now failing when I attempt to use it with 2022b (sorry, I have no info with respect to versions in between). The code itself gets linked into a larger project but now errors out during the link due to the static declaration. I was able maunally fix the code as shown below but really need a better solution.
Code produced by RTW
/* Real-time model */
static RT_MODEL_tx2_T tx2_M_;
RT_MODEL_tx2_T *const tx2_M = &tx2_M_;
Hand modified after error
/* Real-time model */
RT_MODEL_tx2_T tx2_M_;
RT_MODEL_tx2_T *const tx2_M = &tx2_M_;
Link is now successful
Seems simple but the hand mod is not practical to do regularly for this apllication. Are there any settings or tlc files I should be looking at to eliminate the static declaration?
Thank you
  1 个评论
martin a
martin a 2023-4-19
I have found the tlc file that writes this code but I'm not seeing a way to disable while still getting the same style function call.
.\R2022b\rtw\c\tlc\mw\formatparam.tlc
line 593-594
%assign definition = ...
"static %<::tSimStructType> %<modelSS>_;"

请先登录,再进行评论。

回答(1 个)

Ayush
Ayush 2024-9-1
Hi Martin,
It seems that the issue you're facing is related to the static declaration in your custom TLC file. Starting from MATLAB R2019a, the code generation process has been updated, which might be causing the error you're experiencing. To eliminate the static declaration, you can try modifying the TLC file by removing the "static" keyword from the declaration of tx2_M_. Here's an example of how the modified code should look:
/* Real-time model */
RT_MODEL_tx2_T tx2_M_;
RT_MODEL_tx2_T *const tx2_M = &tx2_M_;
By removing the "static" keyword, you should be able to successfully link your code without any errors.
If modifying the TLC file doesn't solve the issue, you can also check if there are any specific code generation settings that might affect the static declaration. You can review the code generation options in the Configuration Parameters dialog in MATLAB.
  1 个评论
martin a
martin a 2024-9-3
Thanks for the answer but the real question was around getting control over the static declaration during the build. I never ended up finding an option that allowed me to fix this directly without modifying a core tlc file. I was trying to avoid that because it would likely cause further issues in a later matlab release.
In the end, I managed to fix this using the ert_make_rtw_hook.m file and having it remove the "static" text before compiling took place.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by