hxdjb 发表于 2025-6-5 22:08

请教两行代码的功能

1:typedef void (*p_time_server_proc_run)(void);

2:extern p_time_server_proc_run   g_time_server_proc_run5;

爱情海玩偶 发表于 2025-6-6 09:58

第一句话是定义了一个函数指针。函数没有返回值。没有传参
第二句话是把g_time_server_proc_run5变量对外声明。

举例说明:
我在a.c文件里面这样写的
typedef void (*p_time_server_proc_run)(void);
p_time_server_proc_run   g_time_server_proc_run5;
void func(void)
{
printf("test");
}

g_time_server_proc_run5 = func;

然后我在b.c文件里面想用g_time_server_proc_run5这个全局变量。那么就需要extern这个变量。
等价于
int a;
extern int a;

dffzh 发表于 2025-6-6 11:29

学习一下函数指针就知道是怎么回事了!

NightfallBallad 发表于 2025-6-16 13:20

第一句话是定义了一个函数指针。函数没有返回值。没有传参
第二句话是把g_time_server_proc_run5变量对外声明。
页: [1]
查看完整版本: 请教两行代码的功能