GNU* gcc* から Microsoft* Visual C++* への移植

GNU gcc から Microsoft Visual C++ へ移植する際に -diag-enable port-win オプションを使用して一般的な構文の問題に関する警告を表示することができます。次に、このオプションを使用した例を示します。

例 1:

$ cat -n attribute.c

     1  int main()

     2  {

     3    int i __attribute__((unused));

     4    return 0;

     5  }

$ icc -c -diag-enable port-win attribute.c

attribute.c(3): warning #2133: attributes are a GNU extension

    int i __attribute__((unused));

             ^

 例 2:

$ cat -n state_expr.c

     1  int main()

     2  {

     3    int i = ({ int j; j = 1; j--; j;});

     4    return i;

     5  }

$ icc -c -diag-enable port-win state_expr.c

state_expr.c(3): warning #2132: statement expressions are a GNU extension

    int i = ({ int j; j = 1; j--; j;});

             ^