在浏览cppreference时,我在函数参数中看到了一个奇怪的类型数组,如下所示:
void f(double x[volatile], const double y[volatile]);
那么,volatile
关键字出现在数组下标中的目的是什么?它有什么作用?
最佳答案
volatile
关键字用于声明函数参数的数组类型。
这里,double x[volatile]
等同于double * volatile x
。
In a function declaration, the keyword
volatile
may appear inside the square brackets that are used to declare an array type of a function parameter. It qualifies the pointer type to which the array type is transformed. The following two declarations declare the same function:void f(double x[volatile], const double y[volatile]); void f(double * volatile x, const double * volatile y);
此语法仅在 C 语言的函数参数中有效。
关于c - 出现在数组下标中的 "volatile"关键字的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47377106/