简体   繁体   English

C - 以下代码中变量的类型定义是什么?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM