The following examples show the effects of compiling this code with the -filt option.
// filt_demo.cc
class type {
public:
virtual ~type(); // no definition provided
};
int main()
{
type t;
}
|
When you compile the code without the -filt option, the compiler assumes -filt=errors,names,returns,stdlib and displays the standard output.
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 |
The following command suppresses the demangling of the of the C++ mangled linker names and suppresses the C++ explanations of linker errors.
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 |
Now consider this code:
#include <string>
#include <list>
int main()
{
std::list<int> l;
std::string s(l); // error here
}
|
Here’s the output when you specify -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>>. |
Here’s the output when you specify -filt=stdlib:
Error: Cannot use std::list<int> to initialize std::string . |