包括不同版本的 glib 头文件

发布于 2024-09-07 20:25:36 字数 174 浏览 12 评论 0原文

假设有两个源文件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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰ゝ天使的微笑 2024-09-14 20:25:36

它不应该造成问题。这是因为 GLib 维护了 2.x 系列中所有版本的 API 兼容性。无论您使用哪个版本的标头来编译程序,您都可以链接到任何版本的库,只要您不使用该版本的库中不存在的任何功能即可。

然而,你似乎让你的生活变得不必要的困难:

我正在使用一个可以指定的 Makefile
GLiB 的根目录并使用
#include "glib.h" 在代码中。我有多个版本的 glib 标头
已安装。

你到底为什么要这么做?

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:

I'm using a Makefile that can specify
the root directory of GLiB and using
#include "glib.h" in the code. I have multiple versions of glib headers
installed.

Why on earth would you want to do that??

可遇━不可求 2024-09-14 20:25:36

请参阅此比较表了解 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.

enter image description here

...

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文