将限制关键字用于2d数组函数参数的语法是什么? [英] What is the syntax for using the restrict keyword for a 2d array function parameter?

查看:104
本文介绍了将限制关键字用于2d数组函数参数的语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主函数中声明了一个数组: float A[n][n];

I have an array declared in my main function: float A[n][n];

我的目标是使用restrict关键字将其传递给函数: void func(int n, float restrict A[][n])

My goal is to pass it to a function with the restrict keyword: void func(int n, float restrict A[][n])

我尝试了上面的语法,但是我没有获得期望的运行时间优化.我也看到了1d数组的这种语法: void func(int n, float A[restrict])

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])

推荐答案

可以限制指针.以下所有形式都是等效的:

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]);

这篇关于将限制关键字用于2d数组函数参数的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆