Strange saying C

void test(int x[static 10]); int main() { int a[]={1,2,3,4,5,6,7,8,9,10,11}; test(a); return 0; } void test(int x[static 10]) { printf("%d",x[9]); } 

I searched for C's bizarre sayings. I found this, but couldn't figure out what static 10 uses in this statement. Is it the same as int x[10] ?

Another thing, you can use volatile also instead of static eg int x[volatile 10]
Does anyone know what the use of this kind of declaration is?

PS: Compiled using GCC 4.6.3,

+6
source share
1 answer

This is a compiler hint indicating that the pointer parameter x points to the first element of the array at least 10 .

For instance:

 test(NULL); // undefined behavior 
+5
source

Source: https://habr.com/ru/post/949668/


All Articles