使用されていない変数への警告を避ける方法

  • 分からなかった
    • boost::ignore_unused_variable_warningというのがあるが、使っていいのか不明
  • x;も警告の対象になっている・・・参照
  • Comeauだと(void)x;でも警告がでる
  • void型へのキャストについて・・・参照
  • というわけで、世界で一番簡単な関数unused・・・ダウンロード


[]#include[] []<pstade/unused.hpp>[]

[]struct[] []X[][]; [][]// declaration only[]

[]X[][]& [][]foo[][]();[]

[]void[] []test[][]([][]X[][]& [][]x1[][], [][]X[][]& [][]x2[][])[]
[]{[]
[]pstade[][]::[][]unused[][]([][]x1[][], [][]x2[][]);[]

[]// foo(); // error C2027 under VC8[]
[]pstade[][]::[][]unused[][]([][]foo[][]()); [][]// ok[]
[]}[]