Is there a g++ equivalent to Visual Studio#39;s __declspec(novtable)?(是否有与 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++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有与 Visual Studio 的 __declspec(novtable) 等效的 g++?


基础教程推荐
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01