私はこの定義を持っています:
static const char* STRING_ARRAY[NUM_UNITS] = STRING_ARRAY_VALUES;
いつ
#define STRING_ARRAY_VALUES \
{ "n/a", \
"bool", \
... \
}
残念ながら、MISRA-C++ルール8-5-2に準拠していません。
"MISRA-C++ Rule 8-5-2 (required): Braces shall be used to indicate and match the
structure in the non-zero initialization of arrays and structures."
なぜ準拠していないのか説明してもらえますか?#defineコマンドは定義を次のようなものに変えると思いました:
static const char* STRING_ARRAY[NUM_UNITS] = {"n/a", "bool",...}
これはMISRAルールに準拠しています。
を維持しながら、これをMISRAに準拠させる方法はあり#define
ますか?