问题
I have an array declared in my main function:
float A[n][n];
My goal is to pass it to a function with the restrict
keyword:
void func(int n, float restrict A[][n])
I tried the syntax above, but I am not getting the optimization in running time that I am expecting. I have also seen this syntax for 1d arrays:
void func(int n, float A[restrict])
回答1:
The pointer can be restrict. All below forms are equivalent:
void func(int n, float A[restrict n][n]);
void func(int n, float A[restrict][n]);
void func(int n, float (* restrict A)[n]);
来源:https://stackoverflow.com/questions/60243068/what-is-the-syntax-for-using-the-restrict-keyword-for-a-2d-array-function-parame