c语言函数指针使用例子
一、是什么?
c语言函数名是一段代码首地址,连接器链接时放在text段,下面例子会把函数名打印出来,.map文件内存分布查看相关代码段函数:
下面例子实现步骤: 来源于uboot 的初始化 board_f.c
typedef int (*init_fun_t)(void);
(1)构建gd数据类型
(2)初始化全局gd变量
(3)实现指针函数内容
(4)循环遍历初始化
# 二、使用步骤
## 1.引入库
代码如下(示例):```c
/** Definitions for Command Processor*/
#ifndef __COMMAND_H
#define __COMMAND_Htypedef struct global_data gd_t;
typedef unsigned long phys_addr_t;
typedef unsigned long phys_size_t;struct arch_global_data
{unsigned long dcache_line_size;unsigned long icache_line_size;unsigned long dcache_size;unsigned long icache_size;unsigned long reset_addr;unsigned long exception_addr;int has_initda;int has_mmu;int io_region_base;int mem_region_base;int physaddr_mask;
};struct bd_info
{unsigned long bi_flash_start;unsigned long bi_flashsize;unsigned long bi_flashoffset;unsig