<分区>
我最近发现了 static
关键字的新用法。
static
在这里是什么意思?
void fun(int some_array[static 7]);
编辑:有人可以举一个有用的例子吗?
<分区>
我最近发现了 static
关键字的新用法。
static
在这里是什么意思?
void fun(int some_array[static 7]);
编辑:有人可以举一个有用的例子吗?
最佳答案
标准在 6.7.6.3 中说:
A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression.
这是 C99 中引入的功能。所以你有它:some_array
必须至少有 7 个元素长。
正如他们所说,如果关键字 static
没有新用法,就不可能有新标准。
关于c - array [] 括号内的 static 关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14942520/