我在共享库中有这个类:
class Interface {
int m_ref;
public:
FOO_EXPORT virtual ~Interface();
virtual void foo() = 0;
protected:
void ref() { ++m_ref; }
bool deref() { return --m_ref; }
};
// cpp file:
Interface::~Interface() {}
Run Code Online (Sandbox Code Playgroud)
哪里FOO_EXPORT是__attribute__((visibility=default))GCC 的,我正在使用-fvisibiliy=hidden -fvisibility-inlines-hidden.
但是当我使用Interface另一个库中的 时,我得到了 typeinfo 和 vtable 的未定义引用。
在 MSVC 上,其中FOO_EXPORT) declspec(dllexport/dllimport` 工作正常,因为导出虚拟函数时会导出 vtable。
我当然可以导出整个班级:
类 FOO_EXPORT 接口 {
但这也导出所有内联方法。
是否有一个中间立场,仅导出~Interface()vtable,而没有其他内容?
如果您知道:为什么 GCC 与 MSVC 不兼容?
| 归档时间: |
|
| 查看次数: |
1365 次 |
| 最近记录: |