C and C++


LANG.PREPROC.ICONST : Inappropriate Argument to Integer Constant Macro

要旨

The argument to an integer constant macro:

See also Use of <stdint.h> Small Integer Constant Macro.

プロパティ

クラス名 Inappropriate Argument to Integer Constant Macro
日本語クラス名 Inappropriate Argument to Integer Constant Macro
クラス分類 信頼性 (reliability)
ニーモニック LANG.PREPROC.ICONST
カテゴリー
MisraC2023 MisraC2023:7.5 The argument of an integer constant macro shall have an appropriate form
Misra2012 Misra2012:7.5 The argument of an integer constant macro shall have an appropriate form
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Inappropriate Argument to Integer Constant Macro"

#include <stdint.h>

uint32_t g1 = UINT32_C(1);               /* ok */

uint32_t g2 = UINT32_C(-1);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - macro name UNIT32_C indicates a 32-bit unsigned integer
                              * - argument -1 is not representable as a 32-bit unsigned integer
                              */

uint32_t g3 = UINT32_C(1u);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument 1u has a literal suffix
                              */

uint32_t g4 = UINT32_C(1.0); /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument is not an integer
                              */

uint32_t g5 = UINT32_C(g1);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument is not a literal
                              */

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。