Function 对函数指针的质疑
在上面的代码中,我对行IAP IAP_条目感到困惑;IAP是一个函数指针。什么是IAP IAP_条目和IAP_条目=(IAP)IAP_位置;什么意思 我习惯于使用下面给出的风格的函数指针Function 对函数指针的质疑,function,function-pointers,Function,Function Pointers,在上面的代码中,我对行IAP IAP_条目感到困惑;IAP是一个函数指针。什么是IAP IAP_条目和IAP_条目=(IAP)IAP_位置;什么意思 我习惯于使用下面给出的风格的函数指针 #define IAP_LOCATION 0X1F00FFFF int iap_program(unsigned int target_addr, unsigned int source_addr) { typedef void(*IAP)(unsigned int[], unsigned int
#define IAP_LOCATION 0X1F00FFFF
int iap_program(unsigned int target_addr, unsigned int source_addr)
{
typedef void(*IAP)(unsigned int[], unsigned int[]);
IAP iap_entry;
iap_entry = (IAP) IAP_LOCATION;
command[0] = 50; // prepare the sector for write operation
command[1] = 7; // start sector no
command[2] = 7; // end sector no
iap_entry (command, result);
}
IAP
不是函数指针。它是一种函数指针类型。(与int
是数字类型,而不是数字本身相同)
iap\u条目
是一个函数指针,类型为iap
(IAP)IAP_LOCATION
也是一个函数指针,类型为IAP
,通过将整数转换为指针生成
float funct(float num1, float num2 )
{
return num1 * num2;
}
typedef float(*pt2Func)(float, float);
pt2Func *FnPtr = &funct;
float result = (*FnPtr)(2.0, 5.1);
}