ホーム > ユーザーサポート > FAQ カバレッジマスターwinAMS
【質問】
CasePlayer2での解析時に、構造体/共用体メンバにアクセスする行で解析エラーが発生します。どのように対処すれば良いですか?
【回答】
その構造体/共用体内に、「無名構造体」「無名共用体」型のメンバがあるのが原因です。
typedef union {
struct {
unsigned char aaa;
unsigned short bbb;
unsigned long ccc;
}; // ☆
unsigned char BYTE[20];
} UTable;
int test(int a)
{
UTable table;
if (a < 0) {
return -1;
}
table.aaa = 1; // ★
return a;
}
仕様書生成開始...
Cソースの詳細解析中...
C:\SL1\SL1 0 Management\support\etc\FAQ\019_09\test\src\test.c
CasePlayer2-E-SYN : 名前( aaa )が宣言されていません.
C:\SL1\SL1 0 Management\support\etc\FAQ\019_09\test\src\test.c(18)
CasePlayer2-I-COMP : エラー:1 警告:0
仕様書生成エラー終了.
無名構造体を用いたメンバへのアクセスはGCCで導入された拡張ですので、CasePlayer2デフォルトの「ANSI-C」モードでは解析エラーになります。
■回避法
CasePlayer2の解析モードを「GNU-C」に変更することによってエラー回避できます。
typedef union {
struct {
unsigned char aaa;
unsigned short bbb;
unsigned long ccc;
} ST; // ☆
unsigned char BYTE[20];
} UTable;
int test(int a)
{
UTable table;
if (a < 0) {
return -1;
}
table.ST.aaa = 1; // ★
return a;
}