2017-05-08 77 views
0

我们是否需要在方法的声明和定义中使用restrict关键字,还是仅仅在C++代码中的声明文件中使用它就足够了?什么是正确的使用方法?在头文件和源文件中限制使用

代码编译即使没有限制在声明中的用法。

例如

Foo.h 
class Foo 
{ 
    public: 
    void Bar(int* __restrict__ in, int* __restrict__ out); 
} 


Foo.cpp 

void Foo::Bar(int* __restrict__ in, int* __restrict__ out) 
{ 
} 
+3

[**“正如所有最参数预选赛,'__restrict__'在函数定义匹配忽略不计。这意味着你只需要在函数定义中指定'__restrict__',而不是在函数原型中。“**](https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html) – StoryTeller

回答

0

从接受答案@StoryTeller

As with all outermost parameter qualifiers, __restrict__ is ignored in 
function definition matching. This means you only need to specify __restrict__ in 
a function definition, rather than in a function prototype as well." – StoryTeller 
May 8 at 10:25 
相关问题