u-boot中typedef应用解析___init_fnc_t *init_sequence[]
2011-11-16 19:16
309 查看
/*这里定义了一个新的数据类型init_fnc_t, *这个数据类型是参数为空,返回值为int的函数。 */ typedef int (init_fnc_t) (void); /*init_sequence是一个指针数组,指向的是init_fnc_t类型的函数*/ init_fnc_t *init_sequence[] = { cpu_init, /* basic cpu dependent setup */ board_init, /* basic board dependent setup */ interrupt_init, /* set up exceptions */ env_init, /* initialize environment */ init_baudrate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ display_banner, /* say that we are here */ dram_init, /* configure available RAM banks */ display_dram_config, #if defined(CONFIG_VCMA9) || defined (CONFIG_CMC_PU2) checkboard, #endif NULL, }; /*init_fnc_ptr为指向函数指针的指针*/ init_fnc_t **init_fnc_ptr; /*init_fnc_ptr初始化指向init_sequence指针数组,下面的循环遇到NULL结束*/ for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) {/*(*init_fnc_ptr)()为C中调用指针指向的函数*/ hang (); } } |
一个typedef int (test_fnc_t) (void);
一个typedef int (*test_fnc_t) (void);
#include<stdio.h> int test0 (void); int test1 (void); typedef int (*test_fnc_t) (void); test_fnc_t test_sequence[] = { test0, test1, NULL, }; //int _tmain(int argc, _TCHAR* argv[]) int main() { test_fnc_t *test_fnc_ptr; for (test_fnc_ptr = test_sequence; *test_fnc_ptr; ++test_fnc_ptr) { if ((*test_fnc_ptr)() != 0) { printf("error here!"); } } return 0; } int test0 (void) { printf("test0\n"); return 0; } int test1 (void) { printf("test1\n"); return 0; } |
#include<stdio.h> int test0 (void); int test1 (void); typedef int (test_fnc_t) (void); test_fnc_t *test_sequence[] = { test0, test1, NULL, }; //int _tmain(int argc, _TCHAR* argv[]) int main() { test_fnc_t **test_fnc_ptr; for (test_fnc_ptr = test_sequence; *test_fnc_ptr; ++test_fnc_ptr) { if ((*test_fnc_ptr)() != 0) { printf("error here!"); } } return 0; } int test0 (void) { printf("test0\n"); return 0; } int test1 (void) { printf("test1\n"); return 0; }
相关文章推荐
- u-boot中typedef应用解析___init_fnc_t *init_sequence[](
- typedef用法解析-->针对uboot中__init_fnc_t *init_sequence[]
- uboot中typedef int (init_fnc_t) (void);详解
- 深入剖析u-boot代码typedef int (init_fnc_t) (void)
- init_fnc_t *init_sequence[] 函数解析
- 【转】u-boot中typedef应用解析
- linux内核学习初笔记(3)u-boot执行第二阶段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)
- NanoPC-T2 Uboot启动过程分析 - 2-4 init_sequence_f[] part 2
- 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);的理解
- uboot下init_sequence_f函数之copy_uboot_to_ram
- 详细解析Python中__init__()方法的高级应用
- typedef int(init_fnc_t) (void) 和 typedef int(*init_fnc_t) (void);