是否有与 Visual Studio 的 __declspec(novtable) 等效的 g++? [英] Is there a g++ equivalent to Visual Studio's __declspec(novtable)?

查看:38
本文介绍了是否有与 Visual Studio 的 __declspec(novtable) 等效的 g++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有与 Visual Studio 的 __declspec(novtable) 参数等效的 g++?

Is there a g++ equivalent to Visual Studio's __declspec(novtable) argument?

基本上,在纯虚拟基类中,__declspec(novtable) 参数可用于禁止为基类创建 vtable 以及在 contstructor/分别为析构函数.例如,

Basically, in a pure virtual base class the __declspec(novtable) argument can be used to suppress the creation of a vtable for the base class as well as vtable initialization/deinitialization code in the contstructor/destructor respectively. E.g.,

class __declspec(novtable) PureVirtualBaseClass
{
    public: 
       PureVirtualBaseClass(){}
       virtual ~PureVirtualBaseClass() = 0;
};

有关详细信息,请参阅 Paul DiLascia 的文章.另请参阅我的相关 问题.

See Paul DiLascia's article for more info. Also see my related question.

推荐答案

我不认为有——如果有,它会列在 类型属性页面.GCC 使用类型属性为类型添加额外的注释(例如对齐和填充),但没有与 __declspc(novtable) 列出的类型属性等效.

I don't think there is one -- if there was, it would be listed under the type attributes page of the GCC manual. GCC uses type attributes to add extra annotations to types (such as alignment and padding), but there is no type attribute equivalent to __declspc(novtable) listed there.

我也没有在 命令行选项中看到任何编译器标志 与此优化有关.

I also don't see any compiler flag in the command line options relating to this optimization.

这篇关于是否有与 Visual Studio 的 __declspec(novtable) 等效的 g++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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