"" に関する原因と対処

このコンパイルエラーの原因と対処に関して説明します。

スポンサード リンク

Microsoft Visual C++にて以下のソースでコンパイルエラーが発生します:

コンパイルエラーメッセージ:
error C2208: 'int': メンバーのない列挙型、構造体、共用体が定義されました。

ソース(バグ有り):

//構造体のサンプル
#include <stdio.h>

int main(void)
{
struct
{
int ;
int y;
} a, b;
a.x = 1;
a.y = 1;
b = a;
printf("b.x = %d\n", b.x);
printf("b.y = %d\n", b.y);
return 0; }


原因:


対処:


ソース(修正済み):

//構造体のサンプル
#include <stdio.h>

int main(void)
{
struct
{
int x;
int y;
} a, b;
a.x = 1;
a.y = 1;
b = a;
printf("b.x = %d\n", b.x);
printf("b.y = %d\n", b.y);
return 0; }

スポンサード リンク



[コンパイルエラーコード、メッセージに戻る]