我正在使用 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 int
和guint
之间不需要转换,它们是相同的类型。
有关 unsigned int
和 int
之间转换的常见警告适用。
关于c - Glib 类型(例如 guint)到标准 C 数据类型(例如 int)之间的类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46517824/