int dif[4]=0; dif[0] = RectB.x + RectB.w - RectA.x; // AがBの右側から食い込んでいる長さ dif[1] = RectA.x + RectA.w - RectB.x; // 左側 dif[2] = RectB.y + RectB.h - RectA.y; // 上側 dif[3] = RectA.y + RectA.h - RectB.y; // 下側 int dif_rl = (dif[0] < dif[1]) ? 0 : 1; int dif_ur = (dif[2] < dif[3]) ? 2 : 3; int dif_dir = (dif_rl < dif_ur) ? dif_rl : dif_ur; switch(dif_dir) { case 0: // 右側で衝突 break; case 1: // 左側 break; case 2: // 上側 break; case 3: // 下側 break; default: break; }
Standard input is empty
prog.c:1:1: error: invalid initializer int dif[4]=0; ^ prog.c:2:1: warning: data definition has no type or storage class [enabled by default] dif[0] = RectB.x + RectB.w - RectA.x; // AがBの右側から食い込んでいる長さ ^ prog.c:2:1: warning: type defaults to ‘int’ in declaration of ‘dif’ [-Wimplicit-int] prog.c:2:1: error: conflicting types for ‘dif’ prog.c:1:5: note: previous definition of ‘dif’ was here int dif[4]=0; ^ prog.c:2:10: error: ‘RectB’ undeclared here (not in a function) dif[0] = RectB.x + RectB.w - RectA.x; // AがBの右側から食い込んでいる長さ ^ prog.c:2:30: error: ‘RectA’ undeclared here (not in a function) dif[0] = RectB.x + RectB.w - RectA.x; // AがBの右側から食い込んでいる長さ ^ prog.c:3:1: warning: data definition has no type or storage class [enabled by default] dif[1] = RectA.x + RectA.w - RectB.x; // 左側 ^ prog.c:3:1: warning: type defaults to ‘int’ in declaration of ‘dif’ [-Wimplicit-int] prog.c:3:1: error: conflicting types for ‘dif’ prog.c:1:5: note: previous definition of ‘dif’ was here int dif[4]=0; ^ prog.c:4:1: warning: data definition has no type or storage class [enabled by default] dif[2] = RectB.y + RectB.h - RectA.y; // 上側 ^ prog.c:4:1: warning: type defaults to ‘int’ in declaration of ‘dif’ [-Wimplicit-int] prog.c:4:1: error: conflicting types for ‘dif’ prog.c:1:5: note: previous definition of ‘dif’ was here int dif[4]=0; ^ prog.c:5:1: warning: data definition has no type or storage class [enabled by default] dif[3] = RectA.y + RectA.h - RectB.y; // 下側 ^ prog.c:5:1: warning: type defaults to ‘int’ in declaration of ‘dif’ [-Wimplicit-int] prog.c:5:1: error: conflicting types for ‘dif’ prog.c:1:5: note: previous definition of ‘dif’ was here int dif[4]=0; ^ prog.c:7:1: error: initializer element is not constant int dif_rl = (dif[0] < dif[1]) ? 0 : 1; ^ prog.c:8:1: error: initializer element is not constant int dif_ur = (dif[2] < dif[3]) ? 2 : 3; ^ prog.c:9:1: error: initializer element is not constant int dif_dir = (dif_rl < dif_ur) ? dif_rl : dif_ur; ^ prog.c:11:1: error: expected identifier or ‘(’ before ‘switch’ switch(dif_dir) ^
Standard output is empty