C and C++


LANG.PREPROC.NBPE : 非ブーリアンプリプロセッサ表現

要旨

プリプロセッサの制御表現 #if あるいは #elifディレクティブが評価され、値が10 以外であるとき、ワーニングを検出します。

評価されない制御表現は、プログラムに一切影響しないため、このワーニングクラスは検出されません。

プロパティ

クラス名 Non-Boolean Preprocessor Expression
日本語クラス名 非ブーリアンプリプロセッサ表現
クラス分類 スタイル (style)
ニーモニック LANG.PREPROC.NBPE
カテゴリー
MisraC2023 MisraC2023:20.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
Misra2012 Misra2012:20.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
POW10 POW10:8 Limit the use of the preprocessor to file inclusion and simple macros.
JPL JPL:20 Make only very limited use of the C pre-processor.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Non-Boolean Preprocessor Expression"

#define ONE 1
#define TWO 2

#if TWO           /* 'Non-Boolean Preprocessor Expression' warning issued here. */
/* ... */
#endif 

#if TWO > ONE                 /* Boolean */
/* ... */
#endif 


#if !ONE                      /* Boolean */
/* ... */
#if TWO                       /* Not evaluated: !ONE always evaluates to FALSE. */
/* ... */
#endif
/* ... */
#endif 

#if ONE                       /* Boolean */
/* ... */
#elif TWO                     /* Not evaluated: ONE always evaluates to TRUE. */
/* ... */
#endif

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

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