用C语言编写递归程序,用C语言递归声明函数

你不能.该类型无法表达,因为它会重复:

void f(void g(void h(...

但是你可以编写一个接受自己的函数,没有任何问题.考虑

void f(void g()) { }

int main(void) { f(f); }

那很好. f的参数类型是函数指针(void g()等效于此处的void(* g)())其类型与f的类型兼容. f的参数和call,void()和void(void())中的参数的函数类型的兼容性规则被指定为:

If one type has a parameter type list [the call argument] and the other type is specified by a function declarator that is not part of a function definition and that contains an empty identifer list [the function parameter type], the parameter list shall not have an ellipsis terminator and the type of each parameter shall be compatible with the type that results from the application of the default argument promotions.

两种类型都满足此兼容性规则,因此函数调用已明确定义.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值