سؤال

The following code compiles with g++ 4.7.1 but not clang 3.1

struct A
{
  int foo();
};

int A::foo() __restrict
{
  return 0;
}


int main(int argc, char * argv[])
{
  A a;
  return a.foo();
}

Does clang support __restrict? or is it using a particular syntax?

هل كانت مفيدة؟

المحلول

I don't have clang 3.1 handy, but under clang 4.1, I get this error:

t.cpp:6:8: error: out-of-line definition of 'foo' does not match any declaration
      in 'A'
int A::foo() __restrict
       ^~~
t.cpp:3:7: note: member declaration nearly matches
  int foo();
      ^
1 error generated.

clang 4.1 compiles it successfully if I change the declaration of A::foo to this:

  int foo() __restrict;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top