GCC

GCCとG++でのswitch文内のcaseラベルにおけるconst定数の扱いの違い

GCCとG++でのswitch文内のcaseラベルにおけるconst定数の扱いの違い #include <stdio.h> int main(void) { const int A = 2; int a = 2; switch(a) { case A: puts("ok"); break; } } $ gcc test.c test.c: In function ‘main’: test.c:10: error: case ラベルを整数</stdio.h>…

main=-277;

GCC

$ cat test.c main=-277; $ gcc test.c test.c:1: 警告: データ定義が型や記憶クラスを持っていません $ ./a.out 無限ループ・・・ まずコンパイル通のが不思議。。