【问题标题】:How to solve error: missing binary operator before token "(" on mac?如何解决错误:在mac上的标记“(”之前缺少二元运算符?
【发布时间】:2019-08-29 11:18:43
【问题描述】:

我目前正在尝试在 Mac 上的 virtualenv 中安装 PySift。但是,Zstandard 库在安装时会导致错误。

In file included from /usr/include/Availability.h:236:0,
                     from /usr/include/stdlib.h:61,
                     from zstd/lib/compress/fse_compress.c:38:
    /usr/include/AvailabilityInternal.h:33:18: error: missing binary operator before token "("
     #if __has_include(<AvailabilityInternalPrivate.h>)
                      ^
    In file included from /usr/include/stdlib.h:61:0,
                     from zstd/lib/compress/fse_compress.c:38:
    /usr/include/Availability.h:497:18: error: missing binary operator before token "("
     #if __has_include(<AvailabilityProhibitedInternal.h>)
                      ^
    error: command 'gcc' failed with exit status 1

我在 Stack Overflow 上看到的大多数解决方案通常建议运行 xcode-select --install,但它不起作用。或者,this post 建议使用以下命令

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

该命令将打开一个窗口,允许您安装缺少的 MacOS SDK。然而,它仍然没有奏效。在那之后,我意识到我还没有将 Xcode 更新到最新版本。但即使更新后,错误仍然出现。最后,我尝试使用brew,就像在this post 中一样,并进行一些更新,以防某些损坏的软件阻止安装完成。

我还检查了this post,但没有找到我的答案,因为我专门试图找出为什么__has_include( 之前会导致错误。

最后,它仍然没有工作。我想知道是否有人可以指出我错过了什么导致错误?

【问题讨论】:

标签: python c++ c macos gcc


【解决方案1】:

您从预处理器收到语法错误,b/c 它无法将 __has_include 识别为有效的类似函数的宏。那是因为它是 c++17 特定的指令。

您可以通过从文件中删除该行(以及匹配的#endif)来解决问题。如果您收到有关缺少包含的编译器错误,请同时删除 #include 行。

【讨论】:

  • 这个文件/usr/include/Availability.h似乎是只读的。即使使用 sudo。所以你不能更改文件,因此我仍然有我的问题,在 Mojave 上使用 rbenv 构建 ruby​​ 1.8.7。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 2014-02-15
  • 1970-01-01
相关资源
最近更新 更多