acm*_*acm 17 c++ dll visibility elf visual-c++
在ELF目标上,如果我已经通过类似的声明class Foo给予它default可见性class __attribute__((visibiility("default"))) Foo,那么我可以选择性地default通过明确地用它们注释来使类的某些成员免于可见性__attribute__((visibility("hidden")).这对于不应构成ABI一部分的内联方法非常有用,因此如果在构建库定义时发出class Foo它们,则不会导出它们,或者其中的private成员或类型class Foo也不应构成其ABI的一部分.
但是,在Windows上,似乎没有办法实现这一目标.虽然unadorned class Foo自动私有DLL,但一旦被装饰为class __declspec(dllexport) Foo,整个类现在都是dllexport,并且似乎没有可以选择性地覆盖__dllexport特定成员状态的关联注释.标记选择"不用于导出"成员__declspec(dllimport)显然是错误的.
是否有其他方法可以阻止类作用域__dllexport应用于某些类成员和/或类型?
为了使这更具体,我想说的,并且可以说,当使用ELF注释时:
class __attribute__((visibility("default"))) Foo {
public:
Foo(); // OK, default visibility
// Don't let inlines join the ABI
__attribute__((visibility("hidden")) inline void something() { ... }
private:
// Don't let private members join the ABI
__attribute__((visibility("hidden")) void _internal();
// Our pImpl type is also not part of the ABI.
struct __attribute__((visibility("hidden")) pimpl;
};
Run Code Online (Sandbox Code Playgroud)
但我无法使用MSVC属性形成相同的东西:
class __declspec(dllexport) Foo {
public:
Foo(); // OK, dllexport'ed
// Don't let inlines join the ABI, but how to say it?
__declspec(???) inline void something() { ... }
private:
// Don't let private members join the ABI, but how?
__declspec(???) void _internal();
// Our pImpl type is also not part of the ABI, but how?
struct __declspec(???) pimpl;
};
Run Code Online (Sandbox Code Playgroud)
在现实世界的实现中,我希望它们之间的差异隐藏在宏之后.
是否有一些__declspec我忽略了具有语义__attribute__((visibility("hidden")))并且可以覆盖类范围应用的__declspec(dllexport)?
| 归档时间: |
|
| 查看次数: |
431 次 |
| 最近记录: |