This topic created in 4328 days ago, the information mentioned may be changed or developed.
请问
typedef int Myfunc("const char *, const struct stat *, int");
static Myfunc myfunc;
这段代码应该怎么理解呢?
与
typedef int (*Myfunc)("const char *, const struct stat *, int");
有什么区别呢?
谢谢
Supplement 1 · Jul 26, 2014
typedef int Myfunc(const char *, const struct stat *, int);
static Myfunc myfunc;
这段代码应该怎么理解呢?
与
typedef int (*Myfunc)(const char *, const struct stat *, int);
Note: 写错了多加了一对 双引号 ,下面如果加了*我能明白,不加*我就有点懵了
3 replies • 2014-07-26 23:54:54 +08:00
 |
|
1
wy315700 Jul 26, 2014
Myfunc 是一个函数类型
static的意思是本文件作用域
|
 |
|
2
zeayes Jul 26, 2014 1
typedef int Myfunc(const char *, const struct stat *, int); // Myfunc是一个有3个参数(分别是:const char *, const struct stat *, int)且返回值是int的函数类型。 static Myfunc myfunc; // 申明一个Myfunc类型的静态变量。
typedef int (*Myfunc)(const char *, const struct stat *, int); // Myfunc是一个有3个参数(分别是:const char *, const struct stat *, int)且返回值是int的函数指针。
|
 |
|
3
baka Jul 26, 2014 1
函数名或函数指针对编译器而言,结果实际上是一样的。 以函数名调用的时候,编译器会做function to pointer conversion,这样还是会拿到函数入口指针,相当于做了&myfunc
|