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 个)
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!