c++ - 错误 : "no member named ' uint8_t' in the global namespace"on MacOS

标签 c++ macos cmake

Chriss-MacBook-Pro-2:build louisduplessis$ cmake .. && make
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/utility:203:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:158:8: error: no
      member named 'uint8_t' in the global namespace
using::uint8_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:159:8: error: no
      member named 'uint16_t' in the global namespace
using::uint16_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:160:8: error: no
      member named 'uint32_t' in the global namespace
using::uint32_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:161:8: error: no
      member named 'uint64_t' in the global namespace
using::uint64_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:178:8: error: no
      member named 'uint_fast8_t' in the global namespace
using::uint_fast8_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:179:8: error: no
      member named 'uint_fast16_t' in the global namespace
using::uint_fast16_t;
     ~~^
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:180:8: error: no
      member named 'uint_fast32_t' in the global namespace
using::uint_fast32_t;
     ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/path_planning.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/path_planning.dir/all] Error 2
make: *** [all] Error 2

如何修复这些 fatal error ? 我使用 brew 安装了 cmake,当我升级到新的 Mac 时,这些错误开始出现。

这跟cmake本身的preferences有关系吗?

最佳答案

我在 npm install hummus 或尝试 clang++ test.cpp 时看到同样的错误

      #include <cstdint>

      int main(int argc, char **argv) {
         return 0;
      } 

要编译,请将 Mac SDK 添加到包含路径:

clang++ -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk test.cpp

关于c++ - 错误 : "no member named ' uint8_t' in the global namespace"on MacOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49590038/

相关文章:

c++ - CMake 和 VisualStudio : Group files in solution explorer

c++ - cocos2dx 将从 cocos studio 导出的 Json 运行到动画中

c++ - 函数声明无效。开发C++

c++ - 将 C/C++ 变量放入未命名范围的原因?

c++ - 枚举运算符不工作

macos - -bash : initdb: command not found

eclipse - mac eclipse中运行java应用程序的快捷方式是什么

macos - 适用于 Mac 的 UI 素描软件

c++ - 如何修复 OpenGL Superbible 第 6 版书籍提供的 CMake 文件

c++ - 奇怪的错误: undefined reference to `class::class()'