Why is code generation behavior different in 2018b for the "max" function?
5 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2019 年 1 月 8 日
回答済み: MathWorks Support Team
2019 年 4 月 18 日
I am using MATLAB Coder to generate C code for a Script which calls the "max" function. In 2018a, the generated code would contain an if-else condition to implement the "max" operation, but in 2018b it calls the "fmaxf" function. How do I revert to the earlier code generation behavior?
採用された回答
MathWorks Support Team
2019 年 4 月 19 日
In 2018b, the default standard math library changed to "C99 (ISO)", hence the code generator makes the call to the "fmaxf" function which resides in the same library.
To return to the earlier code generation behavior, please change the standard math library to "C89/90 (ANSI)" in the following manner:
>> cfg = coder.config('dll');
>> cfg.TargetLangStandard = 'C89/C90 (ANSI)';
>> codegen myScript -config cfg -args {1 2 3} % replace the script name and args list accordingly
If you are using the MATLAB Coder App, this option will be found in the Generate Code step under More Settings > Custom Code > Code Replacement Libraries > Standard math library.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!