fork download
  1. int dif[4]=0;
  2. dif[0] = RectB.x + RectB.w - RectA.x; // AがBの右側から食い込んでいる長さ
  3. dif[1] = RectA.x + RectA.w - RectB.x; // 左側
  4. dif[2] = RectB.y + RectB.h - RectA.y; // 上側
  5. dif[3] = RectA.y + RectA.h - RectB.y; // 下側
  6.  
  7. int dif_rl = (dif[0] < dif[1]) ? 0 : 1;
  8. int dif_ur = (dif[2] < dif[3]) ? 2 : 3;
  9. int dif_dir = (dif_rl < dif_ur) ? dif_rl : dif_ur;
  10.  
  11. switch(dif_dir)
  12. {
  13. case 0: // 右側で衝突
  14. break;
  15. case 1: // 左側
  16. break;
  17. case 2: // 上側
  18. break;
  19. case 3: // 下側
  20. break;
  21. default:
  22. break;
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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)
 ^
stdout
Standard output is empty