简体   繁体   English

Boost.Exception符号出现在“ nm”输出中是什么意思? 它们会导致违反ODR吗?

[英]What does it mean when Boost.Exception symbols show up in 'nm' output? Will they cause ODR violations?

I'm running this on a 3rd party statically linked library. 我在第三方静态链接库上运行此代码。 I thought that since it's a header only library (except on some MSVC versions), it wouldn't show up. 我认为,由于它是仅标头的库(某些MSVC版本除外),因此不会显示。 Maybe I'm misunderstanding what nm is supposed to show. 也许我误会了nm应该显示什么。 What I really want to know is if they will cause ODR violations if I'm linking to a library that was compiled with a different version of Boost. 我真正想知道的是,如果我链接到使用其他版本的Boost编译的库,它们是否会导致违反ODR。

See output at: http://codepad.org/kJ86hiQg 在以下位置查看输出: http : //codepad.org/kJ86hiQg

A short sampling: 简短抽样:

    W boost::exception_detail::clone_base::~clone_base()
    W boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> >::~clone_impl()
    W boost::exception_detail::cloning_base::~cloning_base()
    W boost::exception_detail::counted_base::~counted_base()
    W boost::exception::~exception()

These appear to be weak symbols. 这些似乎是微弱的符号。

http://en.wikipedia.org/wiki/Weak_symbol http://en.wikipedia.org/wiki/Weak_symbol


Update ODR violations are not caused by duplicate linker records in the first place. 首先,更新 ODR冲突不是由重复的链接器记录引起的。 They are caused when the compiler uses different definitions of symbols by the same name. 它们是由于编译器使用相同名称使用符号的不同定义而引起的。

So, the short answer is: no nm showing these weak symbols does not cause or indicate ODR violations. 因此,简短的答案是: 没有显示这些弱符号的nm 不会导致或指示违反ODR。 However, the fact that these symbols are weak doesn't imply that there cannot be a ODR violation either. 但是,这些符号较弱的事实并不表示也不能违反ODR。

In fact I think it is perfectly possible to have ODR violations without such symbols (eg when the layout of a struct with the same mangled name is different due to different alignment or packing options) across translation units. 实际上,我认为跨翻译单元在没有此类符号的情况下完全有可能违反ODR(例如,具有相同名称的结构的布局由于对齐方式或打包选项不同而有所不同)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM