是否有与 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.

相关文章