【问题标题】:Compiler error involving restrict keyword [duplicate]涉及限制关键字的编译器错误[重复]
【发布时间】:2012-12-27 18:37:18
【问题描述】:

可能重复:
What does the restrict keyword mean in C++?

我正在尝试在 OS X 10.8.2 上安装 QMCPACK,但遇到很多这样的错误:

bspline_base.h:95:17: error: expected ';' at end of declaration list
void *restrict coefs;
              ^
              ;

我不熟悉restrict关键字,但我觉得这可能是其他类型的问题,因为这是为其他人编译的流行代码。

这是该代码的完整上下文:

typedef struct
{
  spline_code sp_code;
  type_code   t_code;
  void *restrict coefs;
} Bspline;

【问题讨论】:

标签: c++ restrict restrict-qualifier


【解决方案1】:

restrict 不是标准C++ 中的关键字。代码只能在支持restrict 扩展的编译器中编译。

restrict C99 中的一个关键字。因此,如果您使用 C99 编译器,它就可以正常工作。

【讨论】:

    【解决方案2】:

    restrict 仅在 C 模式下可用。 clang++ 将需要 __restrict - 将 -Drestrict=__restrict 添加到编译器标志。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 2022-12-09
      相关资源
      最近更新 更多