clang++ mac os x c++11 linker issue

。_饼干妹妹 提交于 2019-12-06 00:50:27

This is a bug in clang. I can't find a bug report on it though. A bug report would be much appreciated.

The problem is that string::empty is marked "always_inline", but also the string template is marked extern, meaning that it has been instantiated already for you.

For some reason when we have this combination, and you form a member function pointer to the always_inline member, clang refuses to outline it so that it can point to it. It only refuses if the instantiation is marked as extern.

If you disable either the extern, or the always_inline, then the code will work. You can disable the former by including this in "C++ Other Flags":

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