在函数名后声明函数参数 [英] Declaring function parameters after function name

查看:26
本文介绍了在函数名后声明函数参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int func(x)
int x;
{
    .............

这种声明叫什么?

何时有效/无效,包括 C 或 C++、某些标准修订版和编译器?

When is it valid/invalid including C or C++, certain standard revisions and compilers?

推荐答案

它仍然有效,但它是 ANSI 之前的.这实际上就是 K&R 缩进样式得名的地方.左括号在功能块之后的行上,因为这看起来很奇怪:

It's still valid, but it's pre-ANSI. That's actually where the K&R indent style got its name. The opening bracket is on the line after the function block because this looks weird:

int func(x)
int x; {
...
}

无论如何,不​​推荐这种风格,因为函数原型有问题.

Anyway, this style is not recommended because of a problem with function prototypes.

这篇关于在函数名后声明函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆