What does Clang's 'type_visibility' attribute do, and when should one use it?

戏子无情 提交于 2019-12-10 01:23:49

问题


It is used in libc++ on many template types such as tuple_element, tuple, etc.

As far as I can tell there is no public documentation of what it does other than the commit message introducing it and this unit test in the clang project.


回答1:


This attribute allows the ELF visibility of a type and (presumably) its vague linkage objects (vtable, typeinfos) to be controlled separately from the visibility of functions and data members of the type.

This allows typeinfos and the vtable for, say, explicit instantiations of a templated polymorphic type to be located centrally without forcing default visibility on for the type's private static data members as well -- exporting symbols for things that nobody will ever actually access across a library boundary is wasteful of runtime and symbol table space when working with shared libraries.



来源:https://stackoverflow.com/questions/28437772/what-does-clangs-type-visibility-attribute-do-and-when-should-one-use-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!