What is the syntax for using the restrict keyword for a 2d array function parameter?

折月煮酒 提交于 2020-07-16 08:21:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!