typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void)
来源:互联网 发布:vm虚拟机没有网络 编辑:程序博客网 时间:2024/06/10 13:44
typedef int(init_fnc_t) (void);
这个就是一个取别名的过程。我们通常情况下会如下使用 typedef :
typedef int MyInt;
MyInt a;
这个时候我们的MyInt 就和int是一样的意思。
而对于函数的申明我们通常会这样申明:
int InitFunction() (void);此时表示申明了一个函数名为InitFunction的函数, 函数没有任何的形参,返回值类型为int型。
而对于
typedef int(init_fnc_t) (void);
就是对一个 int (void)类型的函数类型进行取别名init_fnc_t。 我们可以利用这个别名进行创建这个类型的函数对象。
init_fnc_t *MyFunction;
这里就是一个函数的指针。如果某个函数的类型和这个函数一样的,那么可以将这个函数的指针指向该函数。然后你就可以直接调用MyFunction();
以下是例子
- C/C++ code
- #include <stdio.h>int GetData(void){ return 101;}int main(){ typedef int (init_fnc_t)(void); typedef int (*init_fnc_t_p)(void); init_fnc_t *MyFunction; init_fnc_t_p MyFunctionP; MyFunction = GetData; MyFunctionP = GetData; printf("(init_fnc_t)(void) = %d \n",MyFunction()); printf("(*init_fnc_t_p)(void) = %d \n",MyFunctionP()); return 0;}
这个时候打印出来的结果就是
101
101
0 0
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void) 区别
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void)
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void)
- typedef int (init_fnc_t) (void)和typedef int (*init_fnc_t) (void)
- typedef int (init_fnc_t) (void);
- typedef int(init_fnc_t) (void);
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void)函数类型和函数指针的区别
- typedef int(init_fnc_t) (void)的解释
- Linux内核之 “typedef int (init_fnc_t) (void);”
- OMAPL138学习---typedef int(init_fnc_t)(void)
- Objective-C 内存管理
- android actionbar自定义样式so easy(一)
- Android APK反编译详解(附图)
- linux下IPTABLES配置详解
- QAxContainerd.lib(qaxbase.obj) : error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“2”不匹配值“0”(DlgCont
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void)
- dizhi
- jQuery.parseJSON( json )
- 解决浏览器不支持javascript问题
- dhcp资料
- oracle全表扫描166G的表只花了6分钟
- 一般区域二重、三重积分MATLAB计算方法
- 多表连接小结
- Visual Studio 2013 + cygwin搭建webkit开发环境