![]() |
![]() |
![]() |
GLib参考手册 | ![]() |
---|---|---|---|---|
Top | Description |
#include <glib.h> #define G_OS_WIN32 #define G_OS_BEOS #define G_OS_UNIX #define G_DIR_SEPARATOR #define G_DIR_SEPARATOR_S #define G_IS_DIR_SEPARATOR (c) #define G_SEARCHPATH_SEPARATOR #define G_SEARCHPATH_SEPARATOR_S #define TRUE #define FALSE #define NULL #define MIN (a, b) #define MAX (a, b) #define ABS (a) #define CLAMP (x, low, high) #define G_STRUCT_MEMBER (member_type, struct_p, struct_offset) #define G_STRUCT_MEMBER_P (struct_p, struct_offset) #define G_STRUCT_OFFSET (struct_type, member) #define G_MEM_ALIGN #define G_CONST_RETURN
#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
检查一个字符是否是目录分隔符。'/'在UNIX机器上,以及'\' 和 '/' 在Windows下,会返回一个TRUE
。
|
一个字符 |
Since 2.6
#define G_SEARCHPATH_SEPARATOR_S ";"
搜索路径分隔字符串。':'是UNIX机器上的,';'则是Windows下的。
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
计算a
和 b
哪个小。
|
一个数值变量。 |
|
一个数值变量。 |
Returns : |
a 和 b 之中更小的 |
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
计算a
和 b
哪个大。
|
一个数值变量。 |
|
一个数值变量。 |
Returns : |
a 和 b 之中更大的 |
#define ABS(a) (((a) < 0) ? -(a) : (a))
计算a
的绝对值。绝对值仅仅是对任何数去掉负号。
例如:
ABS(-10) 绝对值为10.
ABS(10) 还是 10.
|
一个数值变量。 |
Returns : |
a 的绝对值。 |
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
确保x
在low
和 high
之间。如果low
大于high
,结果是未知的。
例如:
CLAMP(5, 10, 15) 结果是 10。
CLAMP(15, 5, 10) 结果是10.
CLAMP(20, 15, 25) 结果是20.
|
the value to clamp.【不清楚这里如何理解】 |
|
允许的最小值。 |
|
允许的最大值。 |
Returns : |
the value of x clamped to the range between low and high . 【不清楚这里如何理解】 |
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset)
返回一个结构体指定偏移量的成员,使用指定类型
|
结构体类型。 |
|
指向结构体的指针 |
|
自结构体起始的偏移,字节类型。 |
Returns : |
结构体成员。 |
#define G_STRUCT_MEMBER_P(struct_p, struct_offset)
返回一个结构体的既定偏移量的无类型指针。
|
指向结构体的指针。 |
|
自结构体起始的偏移,字节类型。 |
Returns : |
指向struct_p 加 struct_offset 个字节数的无类型指针。 |
#define G_STRUCT_OFFSET(struct_type, member)
返回偏移量,字节类型,结构体的成员。
|
结构体类型, e.g. GtkWidget. |
|
结构体的域。e.g. window 。 |
Returns : |
struct_type 的member 的偏移量 |
# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
Indicates the number of bytes to which memory will be aligned on the current platform.
指明当前平台内存对齐的字节数。
#define G_CONST_RETURN
如果 G_DISABLE_CONST_RETURNS
定义了, this macro expands to nothing.
默认情况下,, the macro expands to const
. The macro
should be used in place of const
for functions that
return a value that should not be modified. The purpose of this macro is
to allow us to turn on const
for returned constant
strings by default, while allowing programmers who find that annoying to
turn it off. This macro should only be used for return values and for
out parameters, it doesn't make sense for
in parameters. 【不清楚这里如何理解】