[英]C - What is the type definition of a variable in the following code?
What is the type definition of a variable x
in this code?这段代码中变量
x
的类型定义是什么?
typedef int *f(int);
f *x;
f
is an alias for a function type that takes int
as an argument and returns an int*
. f
是将int
作为参数并返回int*
的函数类型的别名。
As such it isn't particularly useful.因此,它不是特别有用。
(If you wanted f
to be a pointer to a function that takes an int
and returns an int
, you'd have to write typedef int (*f)(int);
) (如果你想让
f
成为一个指向一个接受int
并返回一个int
的函数的指针,你必须写typedef int (*f)(int);
)
typedef int* f(int);
type f
is function with int
parameters and returning pointer to int
.类型
f
是带有int
参数并返回指向int
指针的函数。
You cannot define a function using a typedef
for a function type.不能使用函数类型的
typedef
定义函数。 please see the stack overflow answer.请参阅堆栈溢出答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.