【问题标题】:Does clang++ support __restrict?clang++ 是否支持 __restrict?
【发布时间】:2012-10-06 02:58:19
【问题描述】:

以下代码使用 g++ 4.7.1 编译,但不是 clang 3.1

struct A
{
  int foo();
};

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


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

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

【问题讨论】:

    标签: c++ gcc clang restrict-qualifier


    【解决方案1】:

    我手边没有clang 3.1,但是在clang 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.
    

    如果我将A::foo 的声明更改为此,clang 4.1 编译成功:

      int foo() __restrict;
    

    【讨论】:

    • clang 3.1 给出了同样的错误。不过好吧,很高兴知道这一点。
    • 有 Clang 4.1 吗?主干的最新版本编号为 3.2;是否在主干以外的地方进行开发?
    • Xcode 4.5 包含 clang 4.1。 -v 输出为 Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)。
    • 哦;看起来Apple正在使用他们自己的版本号。这有点奇怪。
    • @JamesMcNellis:是的,当人们也来报告错误时,会造成无穷无尽的麻烦:(
    猜你喜欢
    • 2023-03-08
    • 1970-01-01
    • 2015-03-25
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    相关资源
    最近更新 更多