我应该担心 g++ 吗?警告说“内联失败”?
在我在办公室从事的一个项目中,当我们编译发布版本(使用 -Os)时,我们收到来自 g++ 的数百条警告,指出内联失败。这些警告大多数似乎来自 boost,但有些来自我们自己的库标头(我们链接到的二进制 .dylibs)。通常可以安全地忽略这些警告吗?或者它们是我应该担心的事情吗?
注意:我们在 Mac OS X 上使用 g++ 4.0
In a project I'm working on at the office, when we compile a release build (with -Os) we get hundreds of warnings from g++ saying that inlining has failed. Most of these warnings seem to come from boost, however some come from our own library headers (binary .dylibs that we're linking to). Can these warnings generally be safely ignored, or are they something I should be worried about?
Note: We're using g++ 4.0 on Mac OS X
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
g++ 正在警告本质上严格来说是一个性能问题——您请求的是无法内联的内联实现。如果您使用
inline
并不重要,您应该删除它(编译器能够在没有该提示的情况下内联函数,您知道!-),但就代码正确性而言,您可以忽略警告。如果您对内联的使用确实很重要,即对您的性能至关重要(而不是愚蠢的过早优化),那么警告会告诉您重新编写代码,以便可以实现它(最糟糕的是)在这种情况下,通过转向宏——叹息,但是,当你必须时,你必须!-)。g++ is alerting at what's essentially, strictly a PERFORMANCE problem -- you're requesting
inline
implementations that just can't be inlined. If your use ofinline
doesn't really matter, you should remove it (compilers ARE able to inline functions without that hint, you know!-), but in terms of code correctness, you can ignore the warning. If your use ofinline
really DOES matter, i.e., is crucial to your performance (as opposed to being a silly premature optimization), the warning is telling you to rework your code so it can be achieved (worst case, by moving down to macros -- sigh, but, when you must, you MUST!-).那么它应该保存,
但你应该尽量减少警告。
It should be save if you not
You should try to minimize warnings though.