包括不同版本的 glib 头文件
假设有两个源文件ac和bc: ac 包含 glib-2.6.6 的 glib.h 和 bc 包含 glib-2.12 的 glib.h
然后我编译它们并将它们链接在一起并生成目标程序。假设ac没有使用v2.6之后引入的任何新功能,包含不同版本的标头会导致任何问题吗?如果有的话,什么时候会出现这样的问题?
If there are two source files a.c and b.c:
a.c includes the glib.h of glib-2.6.6
and
b.c includes glib.h of glib-2.12
Then I compile them and link them together and generate target program. Assume that a.c is not using any new feature introduced in after v2.6, will including different version of headers cause any problem? If so, when will such problem happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不应该造成问题。这是因为 GLib 维护了 2.x 系列中所有版本的 API 兼容性。无论您使用哪个版本的标头来编译程序,您都可以链接到任何版本的库,只要您不使用该版本的库中不存在的任何功能即可。
然而,你似乎让你的生活变得不必要的困难:
你到底为什么要这么做?
It shouldn't cause a problem. That's because GLib maintains API compatibility for all versions in the 2.x series. Whatever version of the headers you use to compile your program, you can link to any version of the library, as long as you aren't using any features not present in that version of the library.
However, you seem to be making your life needlessly difficult:
Why on earth would you want to do that??
请参阅此比较表了解 Glib 版本。 2.6.6 和 2.12.0 版本之间进行了一些低严重性的 API/ABI 更改。
...
See this comparison table for Glib versions. There are some low-severity API/ABI changes done between 2.6.6 and 2.12.0 versions.
...