C and C++


LANG.PREPROC.FUNCMACRO : 関数形式マクロの使用

要旨

関数形式マクロが定義されています。

See also Macro Argument is both Mixed and Expanded.

プロパティ

クラス名 Function-Like Macro
日本語クラス名 関数形式マクロの使用
クラス分類 スタイル (style)
ニーモニック LANG.PREPROC.FUNCMACRO
カテゴリー
MisraC2023 MisraC2023:D.4.9 A function should be used in preference to a function-like macro where they are interchangeable
Misra2012 Misra2012:D.4.9 A function should be used in preference to a function-like macro where they are interchangeable
Misra2004 Misra2004:19.7 A function should be used in preference to a function-like macro
AUTOSARC++14 AUTOSARC++14:A16-0-1 The pre-processor shall only be used for unconditional and conditional file inclusion and include guards, and using the following directives: (1) #ifndef, (2) #ifdef, (3) #if, (4) #if defined, (5) #elif, (6) #else, (7) #define, (8) #endif, (9) #include.
MisraC++2008 MisraC++2008:16-0-4 Function-like macros shall not be defined.
MisraC++2023 MisraC++2023:19.0.2 Function-like macros shall not be defined
CERT-C CERT-C:PRE00-C Prefer inline or static functions to function-like macros
  CERT-C:PRE31-C Avoid side effects in arguments to unsafe macros
JSF++ JSF++:29 The #define pre-processor directive shall not be used to create inline macros. Inline functions shall be used instead.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Function-Like Macro"

#define ONE 1                                       /* not function-like */
#define TWO (2)                                     /* not function-like */
#define THREE()(3)      /* 'Function-Like Macro' warning issued here */
#define FOUR(a)(4)      /* 'Function-Like Macro' warning issued here */
#define ADD(a,b)(a+b)   /* 'Function-Like Macro' warning issued here */

/* Macros do not need to be used in order to trigger 'Function-Like Macro' warnings. */

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

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