
C/C++
C/C++
漫索之路
路漫漫其修远兮,吾将上下而求索。
展开
-
2,C语言宏--结构体成员的偏移:#define OFFSET(type, member) ((size_t)(&((type *)0)->member))
宏定义:结构体成员的偏移define OFFSET(type, member) ((size_t)(&((type *)0)->member))member对于(结构体类型)type起始的偏移,type一般为一个结构体类型#include <iostream>#include <stdio.h>using namespace std;typedef struct{ int a; int b; char c; char d;原创 2020-07-20 22:19:09 · 1011 阅读 · 0 评论 -
1, C语言回调函数:依所需条件调用对应回调函数
C回调函数用法#include <stdio.h>typedef void (*func)();typedef struct{ int index; func f_hook;}T_HOOK;void func1(){ printf("I am func1, running...");}void func2(){ printf("I am func2, running...");}T_HOOK t_hook_func[] = {原创 2020-07-06 23:22:02 · 441 阅读 · 0 评论