次の例では、このコードを -filt オプションでコンパイルしたときの影響を示します。
// filt_demo.cc class type { public: virtual ~type(); // no definition provided }; int main() { type t; } |
-filt オプションを指定しないでコードをコンパイルすると、コンパイラでは -filt=errors,names,returns,stdlib が使用され、標準出力が表示されます。
example% CC filt_demo.cc Undefined first referenced symbol in file type::~type() filt_demo.o type::__vtbl filt_demo.o [Hint: try checking whether the first non-inlined, / non-pure virtual function of class type is defined] ld: fatal: Symbol referencing errors. No output written to a.out |
次のコマンドでは、C++ で符号化されたリンカー名の復号化が抑止され、C++ のリンカーエラーの説明が抑止されます。
example% CC -filt=no%names,no%errors filt_demo.cc Undefined first referenced symbol in file __1cEtype2T6M_v_ filt_demo.o __1cEtypeG__vtbl_ filt_demo.o ld: fatal: Symbol referencing errors. No output written to a.out |
次のコードについて考えてみましょう。
#include <string> #include <list> int main() { std::list<int> l; std::string s(l); // error here } |
次は、-filt=no%stdlib を指定したときの出力です。
Error: Cannot use std::list<int, std::allocator<int>> to initialize std::basic_string<char, std::char_traits<char>, std::allocator<char>>. |
次は、-filt=stdlib を指定したときの出力です。
Error: Cannot use std::list<int> to initialize std::string . |