has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit

'BaseXml'  has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit

定义了一个基类,出现了上面的警告,具体的类定义如下:

经过搜索发现原因如下:

If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods), it must always have at least one out-of-line virtual method in the class. Without this, the compiler will copy the vtable and RTTI into every .o file that #includes the header, bloating .o file sizes and increasing link times
定义在头文件中的有虚表(这个函数自身有虚函数或者继承的基类有虚函数,这个类就有虚表)的类,必须至少有一个外联函数。如果没有,编译器就会在包含该头文件的.o目标文件中复制虚表和运行时类型标识,这将会导致目标文件大小的膨胀和链接次数的增加。

找到了原因之后修改代码,告警消失。

虽然一些小的告警一般不会影响代码的运行,但是在特定情况下,该问题所产生的影响将会被放大显露出来。所以平时在写代码时应该养成好的习惯,搞清楚每个告警后面的原因,追求0告警,不为代码埋雷。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值