![]() |
![]() |
![]() |
GLib参考手册 | ![]() |
---|---|---|---|---|
Top | Description |
#include <glib.h> typedef gboolean; typedef gpointer; typedef gconstpointer; typedef gchar; typedef guchar; typedef gint; typedef guint; typedef gshort; typedef gushort; typedef glong; typedef gulong; typedef gint8; typedef guint8; typedef gint16; typedef guint16; typedef gint32; typedef guint32; #define G_HAVE_GINT64 typedef gint64; typedef guint64; #define G_GINT64_CONSTANT (val) #define G_GUINT64_CONSTANT (val) typedef gfloat; typedef gdouble; typedef gsize; typedef gssize; typedef goffset; #define G_GOFFSET_CONSTANT (val) typedef gintptr; typedef guintptr;
GLib定义的这些普通的适用类型,分为了4组:
跨平台使用的整型 - gint8, guint8, gint16, guint16, gint32, guint32, gint64, guint64.
与标准C相似但更好用的类型 - gpointer, gconstpointer, guchar, guint, gushort, gulong.
与标准C基本一致的类型【这里拿不定。。】Types which correspond exactly to standard C types, but are included for completeness - gchar, gint, gshort, glong, gfloat, gdouble.
typedef const void *gconstpointer;
一个常数的无类型指针。指针的值不能被更改。
典型的使用在子函数原型上,指出指针所指向的数据是不能被函数更改的。
typedef signed short gint16;
在任何平台上都保证是一个有符号16位整数。 取值范围为 -32,768 到 32,767
要 print 或scan 此类型的值, 使用
G_GINT16_MODIFIER
和(或) G_GINT16_FORMAT
.
typedef unsigned short guint16;
在任何平台上都保证是一个无符号16位整数。 取值范围为0 到 65,535
要 print 或scan 此类型的值, 使用
G_GINT16_MODIFIER
和(或) G_GUINT16_FORMAT
.
typedef signed int gint32;
在任何平台上都保证是一个有符号32位整数。 取值范围为 -2,147,483,648 到 2,147,483,647
要 print 或scan 此类型的值, 使用
G_GINT32_MODIFIER
和(或) G_GINT32_FORMAT
.
typedef unsigned int guint32;
在任何平台上都保证是一个无符号32位整数。 取值范围为 0 到 4,294,967,295
要 print 或scan 此类型的值, 使用
G_GINT32_MODIFIER
和(或) G_GUINT32_FORMAT
.
#define G_HAVE_GINT64 1 /* deprecated, always true */
G_HAVE_GINT64
is deprecated and should not be used in newly-written code. GLib 2.0版以后需要64-bit 整型支持,所以
G_HAVE_GINT64
总是 要定义的。
在任何平台上都保证是一个有符号64位整数。 取值范围为 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
G_GNUC_EXTENSION typedef signed long long gint64;
在任何平台上都保证是一个有符号64位整数。 取值范围为 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
要 print 或scan 此类型的值, 使用
G_GINT64_MODIFIER
和(或) G_GINT64_FORMAT
.
G_GNUC_EXTENSION typedef unsigned long long guint64;
在任何平台上都保证是一个无符号32位整数。 取值范围为 0 到 18,446,744,073,709,551,615
要 print 或scan 此类型的值, 使用
G_GINT64_MODIFIER
和(或) G_GUINT64_FORMAT
.
#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL))
This macro is used to insert 64-bit integer literals into the source code.【不能确定】
|
a literal integer value, e.g. 0x1d636b02300a7aa7. |
#define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL))
This macro is used to insert 64-bit unsigned integer literals into the source code. 【不能确定】
|
a literal integer value, e.g. 0x1d636b02300a7aa7U. |
Since 2.10
typedef unsigned int gsize;
无符号整形,用来储存sizeof的结果,与C99的size_t类型类似。 这个类型能足够存储下一个指针的数据。通常在32为平台上是32位的,在64位平台上是64位的。
要 print 或scan 此类型的值, 使用
G_GSIZE_MODIFIER
和(或) G_GSIZE_FORMAT
.
typedef signed int gssize;
有符号gsize,与大多数平台的ssize_t类型类似。
要 print 或scan 此类型的值, 使用
G_GSIZE_MODIFIER
和(或) G_GSSIZE_FORMAT
.
typedef gint64 goffset;
有符号的整形,用来作为文件偏移。类似于C99的off64_t。 Values of this type can range from G_MINOFFSET to G_MAXOFFSET.
To print or scan values of this type, use
G_GOFFSET_MODIFIER
and/or G_GOFFSET_FORMAT
.
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
This macro is used to insert goffset 64-bit integer literals into the source code. See also G_GINT64_CONSTANT. 【不能确定】
|
a literal integer value, e.g. 0x1d636b02300a7aa7. Since: 2.20 |
typedef signed int gintptr;
Corresponds to the C99 type intptr_t, a signed integer type that can hold any pointer.
To print or scan values of this type, use
G_GINTPTR_MODIFIER
and/or G_GINTPTR_FORMAT
.
typedef unsigned int guintptr;
Corresponds to the C99 type uintptr_t, an unsigned integer type that can hold any pointer.
To print or scan values of this type, use
G_GINTPTR_MODIFIER
and/or G_GUINTPTR_FORMAT
.