Whilst compiling with avr-gcc I have encountered linker errors such as the following:
undefined reference to `__cxa_pure_virtual'
I've found this document which states:
The
__cxa_pure_virtual
function is an error handler that is invoked when a pure virtual function is called.If you are writing a C++ application that has pure virtual functions you must supply your own
__cxa_pure_virtual
error handler function. For example:
extern "C" void __cxa_pure_virtual() { while (1); }
Defining this function as suggested fixes the errors but I'd like to know:
- what the purpose of this function is,
- why I should need to define it myself and
- why it is acceptable to code it as an infinite loop?
gcc
command where you should be usingg++
; I've done it at least once :) – Bove