Why is the preprocessor check #if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) ) being generated in private.h?
37 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2019-2-25
编辑: MathWorks Support Team
2024-8-20
In the generated code for my model, I have noticed that the following code is generated in the "model_private.h" file:
#if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) )
#error Code was generated for compiler with different sized uchar/char. \
Consider adjusting Test hardware word size settings on the \
Hardware Implementation pane to match your compiler word sizes as \
defined in limits.h of the compiler. Alternatively, you can \
select the Test hardware is the same as production hardware option and \
select the Enable portable word sizes option on the Code Generation > \
Verification pane for ERT based targets, which will disable the \
preprocessor word size checks.
#endif
Why is this code being generated?
采纳的回答
MathWorks Support Team
2024-8-20
编辑:MathWorks Support Team
2024-8-20
This code is included when there are fixed-point data types in the model and fixed-point word size checks are enabled. The limit for each type is the max and min values that can be represented by the type. The header file is included to perform some checks on the target (e.g., because fixpoint slope/bias can cause overflow).
The recommended workflow is to set the correct values of the bits in the "Configuration Parameters" -> "Hardware Implementation" -> Device Details section based on the values defined by the compiler in the limits.h file. You can avoid these checks completely in the following way if the customer does not want these checks:
From MATLAB R2024a, this option is available directly as checkbox in 'Configuration Parameters' -> 'Code Generation' -> 'Interface' -> 'Advanced parameters' -> 'Suppress generation of fixed-point word size checks'
Suppress generation of fixed-point word size checks: https://www.mathworks.com/help/releases/R2024a/rtw/ref/suppressgenerationoffixedpointwordsizechecks.html
From MATLAB R2017a onwards you can add a TLC option which will ensure that the Fixed Point Word Size checking code will not be generated. To use this option, navigate to 'Configuration Parameters' -> 'All Parameters' tab. Then search for "TLC Options" and add the following text to the TLC options check box "-aRemoveFixptWordSizeChecks=1".
Configure Generated Code with TLC: https://www.mathworks.com/help/releases/R2024a/ecoder/ug/configuring-generated-code-with-tlc.html
For older versions of MATLAB (before R2017a), you can disable these #define checks by setting the 'TargetPreprocMaxBitsSint' and 'TargetPreprocMaxBitsUint' to a value of '0'. To do this, navigate to 'Configuration Parameters' and click on the 'List' tab on the top of the dialog box. Then search for the above two parameters and set them to '0'. If we generate code then the #define checks will be disabled by #if 0 statements encapsulating the above statements.
0 个评论
更多回答(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!