2012-10-06 193 views
0

下面的代码编译使用g ++ 4.7.1但不铛3.1铿锵++支持__restrict吗?

struct A 
{ 
    int foo(); 
}; 

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


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

是否铛支持__restrict?还是使用特定的语法?

回答

2

我没有铛3.1得心应手,但在铛4.1,我得到这个错误:

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. 

铛4.1编译它成功,如果我改变的A::foo的声明如下:

int foo() __restrict; 
+0

铿锵3.1给出了同样的错误。但没关系,这很好。 – qdii

+1

有一个叮当声4.1?来自中继线的最新版本编号为3.2;发展是在干线以外的某个地方完成的? –

+0

Xcode 4.5包含了clang 4.1。 '-v'输出是'Apple clang 4.1版(tags/Apple/clang-421.11.66)(基于LLVM 3.1svn)'。 –