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)
{
}
[**「正如所有最參數預選賽,'__restrict__'在函數定義匹配忽略不計。這意味着你只需要在函數定義中指定'__restrict__',而不是在函數原型中。「**](https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html) – StoryTeller