typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
来源:互联网 发布:淘宝css颜色代码 编辑:程序博客网 时间:2024/06/10 05:31
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
原文地址:http://blog.csdn.net/panfengsoftware/article/details/7924922
- 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)
- (ios)UIImage,CGImage和CGImageRef之间的转化
- 全志a31 支持电容屏触摸方法
- 以诚感人者,人亦诚而应!
- JAVA 二分法搜索
- java_反射日记
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);
- python多线程模块使用小问题求解
- poj 1860 Currency Exchange :bellman-ford
- java的中文转拼音组件---pinyin4j
- windows下cocos2d-x android打包
- uva 12300 - Smallest Regular Polygon
- itext 5.3.0实现对pdf文件添加(文字和图片)水印
- linux 内核启动过程以及挂载android 根文件系统的过程
- web导出exl