2017-05-08 2 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