gpt4 book ai didi

c - Glib 类型(例如 guint)到标准 C 数据类型(例如 int)之间的类型转换

转载 作者:太空宇宙 更新时间:2023-11-04 06:54:48 26 4
gpt4 key购买 nike

我正在使用 C 代码库,该代码库使用返回 guint 的 API 函数 ( https://developer.gnome.org/glib/stable/glib-Hash-Tables.html#g-hash-table-size )。我需要将其作为整数传递到下游。我想知道是否有任何方法可以做到这一点?

我搜索了文档和 Google,但一无所获。

最佳答案

这些 typedef 的存在本身就让我感到困惑。检查 glib/gtypes.h:

typedef char   gchar;
typedef short gshort;
typedef long glong;
typedef int gint;
typedef gint gboolean;

typedef unsigned char guchar;
typedef unsigned short gushort;
typedef unsigned long gulong;
typedef unsigned int guint;

所以unsigned intguint之间不需要转换,它们是相同的类型。

有关 unsigned intint 之间转换的常见警告适用。

关于c - Glib 类型(例如 guint)到标准 C 数据类型(例如 int)之间的类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46517824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com