这是函数指针?typedef int delete_dir_cb( char* path, int action, int succ,);

feidegengao 2012-12-04 08:53:08
这是函数指针呀?typedef int delete_dir_cb( char* path, int action, int succ);
不是是这样呀?

typedef int (*delet_dir_cb)( char* path, int action, int succ);
...全文
1126 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
whizer 2012-12-05
  • 打赏
  • 举报
回复

typedef int  delete_dir_cb( char* path, int action, int succ); //函数类型
typedef int (*delet_dir_cb)( char* path, int action, int succ);//函数类型指针
参见下面C99标准描述:

typedef int F(void); // type F is ‘‘function with no parameters
                     // returning int’’
EXAMPLE 4 On the other hand, typedef names can be used to improve code readability. All three of the following declarations of the signal function specify exactly the same type, the first without making use of any typedef names.

typedef void fv(int), (*pfv)(int);
void (*signal(int, void (*)(int)))(int);
fv *signal(int, fv *);
pfv signal(int, pfv); 
自信男孩 2012-12-04
  • 打赏
  • 举报
回复
一般指针都是占4个字节(在32位系统中),你可以sizeof();一下:

#include <stdio.h>

typedef int  delete_dir_cb( char* path, int action, int succ);
typedef int (*delete_dir_cb2(char *path, int action, int succ);
int main(int argc, char *argv[])
{
	delete_dir_cb num;
	delete_dir_cb2 num2;
	printf("sizeof(num) = %d\n", sizeof(num));
	printf("sizeof(num2) = %d\n", sizeof(num2));
	return 0;
}
自信男孩 2012-12-04
  • 打赏
  • 举报
回复
typedef int (*delet_dir_cb)( char* path, int action, int succ); 这个是一个函数指针。

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧