XFusion API v1.3.0
|
预定义宏. 如 UNUSED, STR, xf_offsetof, xf_container_of. 更多...
宏定义 | |
#define | __FILENAME__ |
获取不含路径的文件名。 | |
#define | NC (-1) |
空引脚值。当引脚无需使用时填入。 | |
#define | UNUSED(x) do { (void)(x); } while(0) |
未使用的变量通过 UNUSED 防止编译器警告。 | |
#define | CONCAT(a, b) a##b |
拼接。 | |
#define | CONCAT3(a, b, c) a##b##c |
拼接 3 个参数。 | |
#define | XCONCAT(a, b) CONCAT(a, b) |
展开拼接。 与 CONCAT 相比,此宏会先展开宏后拼接。 | |
#define | XCONCAT3(a, b, c) CONCAT3(a, b, c) |
展开拼接 3 个参数。 与 CONCAT3 相比,此宏会先展开宏后拼接。 | |
#define | STR(x) #x |
字符串化。 见:https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html | |
#define | XSTR(x) STR(x) |
参数字符串化。 见:https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html | |
#define | xf_offsetof(type, member) ((size_t)&((type *)0)->member) |
xf_offsetof - 返回结构成员相对于结构开头的字节偏移量。 | |
#define | xf_container_of(ptr, type, member) ((type *)((char *)(ptr) - xf_offsetof(type, member))) |
xf_container_of - 通过结构体成员变量地址获取结构体的地址. | |
#define | ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
ARRAY_SIZE - 获取数组 arr 中的元素数量。 | |
预定义宏. 如 UNUSED, STR, xf_offsetof, xf_container_of.
#define __FILENAME__ |
获取不含路径的文件名。
在文件 xf_predef.h 第 39 行定义.
#define NC (-1) |
空引脚值。当引脚无需使用时填入。
在文件 xf_predef.h 第 51 行定义.
#define UNUSED | ( | x | ) | do { (void)(x); } while(0) |
未使用的变量通过 UNUSED 防止编译器警告。
在文件 xf_predef.h 第 64 行定义.
#define CONCAT | ( | a, | |
b | |||
) | a##b |
拼接。
在文件 xf_predef.h 第 71 行定义.
#define CONCAT3 | ( | a, | |
b, | |||
c | |||
) | a##b##c |
拼接 3 个参数。
在文件 xf_predef.h 第 78 行定义.
#define XCONCAT | ( | a, | |
b | |||
) | CONCAT(a, b) |
展开拼接。 与 CONCAT 相比,此宏会先展开宏后拼接。
在文件 xf_predef.h 第 86 行定义.
#define XCONCAT3 | ( | a, | |
b, | |||
c | |||
) | CONCAT3(a, b, c) |
展开拼接 3 个参数。 与 CONCAT3 相比,此宏会先展开宏后拼接。
在文件 xf_predef.h 第 94 行定义.
#define STR | ( | x | ) | #x |
字符串化。 见:https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html
在文件 xf_predef.h 第 102 行定义.
#define XSTR | ( | x | ) | STR(x) |
参数字符串化。 见:https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html
在文件 xf_predef.h 第 110 行定义.
#define xf_offsetof | ( | type, | |
member | |||
) | ((size_t)&((type *)0)->member) |
xf_offsetof - 返回结构成员相对于结构开头的字节偏移量。
type | 结构体的类型名。 |
member | 结构中成员的名称。 |
在文件 xf_predef.h 第 121 行定义.
#define xf_container_of | ( | ptr, | |
type, | |||
member | |||
) | ((type *)((char *)(ptr) - xf_offsetof(type, member))) |
xf_container_of - 通过结构体成员变量地址获取结构体的地址.
ptr | 指向成员的指针。 |
type | 结构体类型。 |
member | 结构中成员的名称。 |
示例如下:
在文件 xf_predef.h 第 161 行定义.
#define ARRAY_SIZE | ( | arr | ) | (sizeof(arr) / sizeof((arr)[0])) |
ARRAY_SIZE - 获取数组 arr 中的元素数量。
arr | 待求的数组。(必须是数组,此处不进行判断) |
在文件 xf_predef.h 第 173 行定义.