What is the purpose of __cxa_pure_virtual?

前端 未结 2 1846
不知归路
不知归路 2020-12-04 11:19

Whilst compiling with avr-gcc I have encountered linker errors such as the following:

undefined reference to `__cxa_pure_virtual\'

I\'ve foun

2条回答
  •  情书的邮戳
    2020-12-04 11:54

    If anywhere in the runtime of your program an object is created with a virtual function pointer not filled in, and when the corresponding function is called, you will be calling a 'pure virtual function'.

    The handler you describe should be defined in the default libraries that come with your development environment. If you happen to omit the default libraries, you will find this handler undefined: the linker sees a declaration, but no definition. That's when you need to provide your own version.

    The infinite loop is acceptable because it's a 'loud' error: users of your software will immediately notice it. Any other 'loud' implementation is acceptable, too.

提交回复
热议问题