Cygwin gcc 添加下划线“_”我的符号的前缀。在哪里可以找到有关此行为的文档?
我第一次尝试在 cygwin 上编译 gcc 项目。构建失败,因为所有符号都带有下划线前缀。这导致与没有前导下划线的 GLIB 库(通过 CYGWIN 包管理系统安装)符号不匹配。这种放置领先下杠的倾向是否在某个地方有记录?
I am trying to compile a gcc project on cygwin for the first time. The build is failing, because an underbar is being prefixed to all symbols. This is causing a symbol mismatch to the GLIB library (installed via CYGWIN package management system) which does not have the leading underbar. Is this tendency to place a leading underbar documented in some place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Cygwin 的编译器会这样做,因为 Visual C++ 也会这样做。他们试图最大限度地减少两者之间不必要的差异,以帮助将使用其中一种构建的代码链接到使用另一种构建的代码。通常还有其他一些事情会阻止您将 Cygwin 代码与 Visual C++ 一起使用,反之亦然,但这不是其中之一。
Cygwin's compiler does this because Visual C++ does. They're trying to minimize the number of needless differences between the two, to aid linking code built with one to code built with the other. There are often other things that prevent you from using Cygwin code with Visual C++ and vice versa, but this isn't one of them.
使用
-fleading-underscore
和/或-fno-leading-underscore
来获得您想要的行为。 这个问题有很多相关信息你正在做的事情。Use
-fleading-underscore
and/or-fno-leading-underscore
to get the behaviour you want. This question has a lot of information related to what you're doing.