user-0 提问: 奇怪的C语法， 有谁见过这样写函数形参的吗？

回复:
user: user-1
content: 引用 17 楼 fefe82 的回复:[quote=引用 14 楼 lin5161678 的回复:] [quote=引用 12 楼 fefe82 的回复:] 这确实是一种非常古老的写法，但是即使是在 C11 ，这也是一种标准支持的合法的写法。  ========================= C++ 没有这种写法。  C11 支持这个写法吗? 我好像没看到 写在哪?[/quote]  ISO/IEC 9899 2011 6.9.1 Function definitions Syntax 1 function-definition: declaration-specifiers declarator declaration-list(opt) compound-statement declaration-list: declaration declaration-list declaration Constraints 2 The identifier declared in a function definition (which is the name of the function) shall have a function type, as specified by the declarator portion of the function definition.162) 3 The return type of a function shall be void or a complete object type other than array type. 4 The storage-class specifier, if any, in the declaration specifiers shall be either extern or static. 5 If the declarator includes a parameter type list, the declaration of each parameter shall include an identifier, except for the special case of a parameter list consisting of a single parameter of type void, in which case there shall not be an identifier. No declaration list shall follow. 6 If the declarator includes an identifier list, each declaration in the declaration list shall have at least one declarator, those declarators shall declare only identifiers from the identifier list, and every identifier in the identifier list shall be declared. An identifier declared as a typedef name shall not be redeclared as a parameter. The declarations in the declaration list shall contain no storage-class specifier other than register and no initializations.   13 EXAMPLE 1 In the following: extern int max(int a, int b) { return a > b ? a : b; } extern is the storage-class specifier and int is the type specifier; max(int a, int b) is the function declarator; and { return a > b ? a : b; } is the function body. The following similar definition uses the identifier-list form for the parameter declarations: extern int max(a, b) int a, b; { return a > b ? a : b; } Here int a, b; is the declaration list for the parameters. The difference between these two definitions is that the first form acts as a prototype declaration that forces conversion of the arguments of subsequent calls to the function, whereas the second form does not.[/quote] 多谢  学习了

user: user-0
content: 引用 9 楼 lin5161678 的回复:[quote=引用 5 楼 zhu339111520 的回复:] 编译不报错，逗么 然而真的可能不报错 比较古老的写法 已经废弃 但还有一些比较古老的编译器能看懂[/quote]确实是这样的，所以才纳闷，我都写了好几年的代码，都没看过这种写法

user: user-2
content: 引用 14 楼 lin5161678 的回复:[quote=引用 12 楼 fefe82 的回复:] 这确实是一种非常古老的写法，但是即使是在 C11 ，这也是一种标准支持的合法的写法。  ========================= C++ 没有这种写法。  C11 支持这个写法吗? 我好像没看到 写在哪?[/quote]  ISO/IEC 9899 2011 6.9.1 Function definitions Syntax 1 function-definition: declaration-specifiers declarator declaration-list(opt) compound-statement declaration-list: declaration declaration-list declaration Constraints 2 The identifier declared in a function definition (which is the name of the function) shall have a function type, as specified by the declarator portion of the function definition.162) 3 The return type of a function shall be void or a complete object type other than array type. 4 The storage-class specifier, if any, in the declaration specifiers shall be either extern or static. 5 If the declarator includes a parameter type list, the declaration of each parameter shall include an identifier, except for the special case of a parameter list consisting of a single parameter of type void, in which case there shall not be an identifier. No declaration list shall follow. 6 If the declarator includes an identifier list, each declaration in the declaration list shall have at least one declarator, those declarators shall declare only identifiers from the identifier list, and every identifier in the identifier list shall be declared. An identifier declared as a typedef name shall not be redeclared as a parameter. The declarations in the declaration list shall contain no storage-class specifier other than register and no initializations.   13 EXAMPLE 1 In the following: extern int max(int a, int b) { return a > b ? a : b; } extern is the storage-class specifier and int is the type specifier; max(int a, int b) is the function declarator; and { return a > b ? a : b; } is the function body. The following similar definition uses the identifier-list form for the parameter declarations: extern int max(a, b) int a, b; { return a > b ? a : b; } Here int a, b; is the declaration list for the parameters. The difference between these two definitions is that the first form acts as a prototype declaration that forces conversion of the arguments of subsequent calls to the function, whereas the second form does not.

user: user-3
content: 不要用不常用的写法，否则移植可能会出问题

user: user-1
content: 引用 12 楼 fefe82 的回复:这确实是一种非常古老的写法，但是即使是在 C11 ，这也是一种标准支持的合法的写法。  ========================= C++ 没有这种写法。  C11 支持这个写法吗? 我好像没看到 写在哪?

user: user-4
content: 老式C语言写法

user: user-2
content: 这确实是一种非常古老的写法，但是即使是在 C11 ，这也是一种标准支持的合法的写法。  ========================= C++ 没有这种写法。

user: user-5
content: 哈哈~我还这么写过。。。不过我可不老~你的教材可以扔掉了~

user: user-6
content: 老式的 c 语法，比大部分这里回帖的都老。

user: user-1
content: 引用 5 楼 zhu339111520 的回复:编译不报错，逗么 然而真的可能不报错 比较古老的写法 已经废弃 但还有一些比较古老的编译器能看懂

user: user-7
content: 这不是标准的c++

user: user-8
content: 因为C语言没有函数重载，所以函数形参可以放在外面，但这不是标准的C

user: user-9
content: const char * inet_ntop(int af, const void* src, char* dst, size_t size) { 	switch (af) { 	case AF_INET: 		return (inet_ntop4(src, dst, size)); 	case AF_INET6: 		return (inet_ntop6(src, dst, size)); 	default: 		errno = EAFNOSUPPORT; 		return (NULL); 	} 	/* NOTREACHED */ }   这才是c语法

user: user-9
content: 编译不报错，逗么

user: user-10
content: 可读性还是需要考虑的

user: user-11
content: 不好理解的代码；建议不要学，更不要写；因为自己写出来的代码如果都读不懂，如何让别人阅读。

user: user-12
content: K&R C Style

user: user-13
content: 扔了你那些资料，应该超30年了。 C语言标准出来之前的语法。