MATLAB Answers

Why is the preprocessor check #if ( UCHAR_MAX != (0xFFU) ) || ( SCHAR_MAX != (0x7F) ) being generated in private.h?

60 ビュー (過去 30 日間)
この 質問 は 1 人のコントリビューターによってフラグが設定されました
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
MathWorks Support Team 2019 年 4 月 25 日
The above code is being generated because a signal or block with a fixed point data type is being used in your model. Please refer to the link for more details.
  1 件のコメント
John
John 2021 年 2 月 25 日
This code construct is in error for 2 reasons and should be removed/updated from the templates.
1) The LONG and ULONG types are not used in the portable datatypes that the generator creates under the ERT. Where a long type is used, it is not considered to be a specific size.
/*=======================================================================*
* Fixed width word size data types: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
* real32_T, real64_T - 32 and 64 bit floating point numbers *
*=======================================================================*/
typedef signed char int8_T;
typedef unsigned char uint8_T;
typedef short int16_T;
typedef unsigned short uint16_T;
typedef int int32_T;
typedef unsigned int uint32_T;
typedef float real32_T;
typedef double real64_T;
2) Why isn't the fixed size type variables used from <stdint.h> instead of Matlab recreating this? This section ensures that I cannot use the same generated code on separate machine architectures even though the source code is actually identical.

サインインしてコメントする。

その他の回答 (1 件)

Mayur Sathawane
Mayur Sathawane 2019 年 5 月 22 日
Change below porperty in model configuration,
'ERTFilePackagingFormat' to 'Modular', (Code Generation --> Code Placement --> Code Packaging)
This will include model_private.h in code instead.

タグ

タグが未入力です。

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by