如何删除没有虚拟析构函数的多态类类型的对象 [英] How to delete an object of a polymorphic class type that has no virtual destructor

查看:891
本文介绍了如何删除没有虚拟析构函数的多态类类型的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从第三方SDK编译一些代码时,我收到以下错误。

  *描述资源路径位置类型
删除具有非虚拟析构函数的多态类类型'Vendor_sys :: VendorCode'的对象可能导致未定义的行为[-Werror = delete-non-virtual-dtor] PnServer.cpp / PCounter行467 C / C ++问题*






我不知道以满足这个条件,只有部分知识的供应商的SDK,其中大部分繁重的工作是在一个dll或库对象。



我的构建环境是Eclipse Juno gpp。



我在Google中搜索了错误消息,但没有发现此错误的任何实例。



因此,如果我不能修改供应商代码的黑盒部分,我的选项是什么?



这是在make过程中失败的代码:

  delete pData-> unit; 


解决方案

实际上,



现在,我将发送一个错误报告供应商。


I am getting the following error when I try to compile some code from a Third-party SDK.

*Description    Resource    Path    Location    Type
deleting object of polymorphic class type ‘Vendor_sys::VendorCode’ which has non-virtual destructor might cause undefined behaviour [-Werror=delete-non-virtual-dtor]   PnServer.cpp    /PCounter   line 467    C/C++ Problem*


I do not know if its possible to satisfy this condition with only partial knowledge of the Vendor's SDK, where most of the heavy lifting is done in a dll or library object.

My build environment is Eclipse Juno with gpp.

I searched in Google for the error message and did not find any instances of this error.

So, if I cannot modify the black box part of the vendor code, what are my options?

Here is the code that is failing during the make process:

delete pData->unit;

解决方案

Actually, I removed the -Werror switch from the compile and the program compiled.

Now, the messages are just warnings.

I will send a bug report to the vendor.

这篇关于如何删除没有虚拟析构函数的多态类类型的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆