Forum Discussion
Altera_Forum
Honored Contributor
21 years agoThe function __cxa_pure_virtual() is a placeholder function inserted automatically by the compiler. It is used whenever you declare a pure virtual function in a base class (that is, a function that won't have an implementation provided:
class an_abstract_base_class
{
virtual void do_something() = 0;
} Since you can't create instances of an_abstract_base_class, you shouldn't be able to call the non-existant function an_abstract_base_class::do_something(). The compiler still needs to create a vtable (virtual function dispatch table) for abstract classes (those with one or more pure virutal methods like an_abstract_base_class), so it has to put something in the vtable entries corresponding to pure virtual functions: it uses __cxa_pure_virtual(). In properly written code __cxa_pure_virtual() should never get called. If it does somehow get called it's a signal that something has gone seriously wrong with your code. So, to eliminate the undefined reference error you have two choices: Either remove all pure virtual functions from you project, or provide your own version of __cxa_pure_virtual() that doesn't use facilities which aren't available on your hardware platform (e.g. just go into an infinite loop flashing an LED).