gpt4 book ai didi

c++ - 使用 restrict 关键字时出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:13:20 25 4
gpt4 key购买 nike

在下面的例子中:

void foo (double *ptr)
{
const double * restrict const restr_ptr=ptr;
}

我收到这个错误:

error: expected a ";"      const double * restrict  const restr_ptr=ptr;
^

我用 -std=c99 编译,使用 gcc 3.4

有什么想法吗?

最佳答案

在 C++ 中,restrict 不是关键字(Microsoft extensions 除外)。这并不意味着它在 C 中的作用。看起来好像您试图将 C99 模式应用于您的 C++ 编译器。使用C编译器编译C代码,使用C++编译器编译C++。两种语言都不是另一种语言的子集。

关于c++ - 使用 restrict 关键字时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1395396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com