- Check MATLAB Code Generation Options: In MATLAB, go to the "Code Generation" settings and ensure that the "Code interface packaging" option is set to "Nonreusable function." This should prevent the generation of the `rt_roundd` function as an `extern` in the generated code.
- Avoid Using Built-in Functions: If you have any custom code that uses the `rt_roundd` function, consider renaming that function to avoid conflicts with the built-in `rt_roundd` function in the generated code.
- Rename Conflicting Function: If you don't have control over the MATLAB-generated code, you can rename the conflicting `rt_roundd` function in your C code manually. For example, you can rename it to something like `my_rt_roundd` in both the function declaration and the function definition.
- Separate Declaration and Definition: If the function definition is provided separately from the declaration in the generated C code, you can modify the code to keep the declaration `extern` and place the function definition in a separate source file. This way, you won't have a redefinition conflict.
- Check for Code Generation Issues: Ensure that your MATLAB code is written correctly and doesn't contain any issues that might lead to conflicts in the generated C code.
rt_round redefinition problem
10 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I'm using Matlab 2020a with Autosar platform. When I try to generate Autosar code for MPC series microcontroller, it always generates rt_roundd function and its extern. There is an error here, in the same C file, the function declaration is made with extern and the body of this function is in the same file. Then I try to compile the whole project, I get the redefinition error and I can't get past the linking phase. Below you can see the contents written in the C file.
extern real_T rt_roundd(real_T u);
// real_T rt_roundd(real_T u)
// {
// real_T y;
// if (fabs(u) < 4.503599627370496E+15) {
// if (u >= 0.5) {
// y = floor(u + 0.5);
// } else if (u > -0.5) {
// y = 0.0;
// } else {
// y = ceil(u - 0.5);
// }
// } else {
// y = u;
// }
// return y;
// }
0 件のコメント
回答 (1 件)
Mrutyunjaya Hiremath
2023 年 7 月 22 日
It seems like you are encountering a conflict with the `rt_roundd` function in your MATLAB code generation for the Autosar platform. The issue you described occurs because the function is declared as `extern` in one place and defined in the same file. This can cause a redefinition error during the linking phase of compilation.
To resolve this issue, you can try the following steps:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で AUTOSAR Blockset についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!