读书人

静态参数,该如何解决

发布时间: 2013-04-20 19:43:01 作者: rapoo

静态参数
请问在C中可以定义静态(static)的形参吗?
我在TC 2.0中编译不通过,在VC 6.0中编译可以通过,这是为什么?
[解决办法]
void fun(static int x){};
这个??还真没见过这种用法。

TC2.0是比VC6还古老的东西
[解决办法]
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.
[解决办法]
静态形参本身就是个错误概念~
[解决办法]
确实没遇到过静态形参
[解决办法]
这个真不知道
不过有些 compiler 对不应该或不认识的 修饰符等视而不见
[解决办法]
c99允许形参中的static,但用途是另外一回事。

读书人网 >C语言

热点推荐