无法编译任何C++程序;错误:未知类型名称“uint8_t”

2023-11-24

编辑2:问题是不是简单的印刷错误。我在下面的日志中犯了一个拼写错误,我已更正该错误,但问题仍然存在。

编辑:在尝试下面之后,我错误地使用 gcc 而不是 g++ 运行了一次。 g++ 以前就存在这个问题,现在也存在。

我目前使用的是 MacOS High Sierra 盒子。我最近将很多文件从 MacBook Air 移至这台机器,其中包括我认为是 Xcode 的垃圾文件。现在,当我尝试编译一个非常简单的 C++ 程序时:

#include <iostream>

int main()
{
    // VAR_DEC
    int a = 4;
    // VAR_MANIP
    a = a*2;
    // VAR_PRINT
    std::cout << a << std::endl;
    return 0;
}

我收到以下荒谬的错误:

jrfarah@Josephs-MBP: [config_file_script] $ g++ test.cpp -o test
In file included from test.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string:470:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view:171:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__string:56:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:640:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:629:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
/usr/include/sys/resource.h:196:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/usr/include/sys/resource.h:197:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:198:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:199:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;
        ^
/usr/include/sys/resource.h:200:2: error: unknown type name 'uint64_t'
        uint64_t ri_interrupt_wkups;
        ^
/usr/include/sys/resource.h:201:2: error: unknown type name 'uint64_t'
        uint64_t ri_pageins;
        ^
/usr/include/sys/resource.h:202:2: error: unknown type name 'uint64_t'
        uint64_t ri_wired_size;
        ^
/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t'
        uint64_t ri_resident_size;
        ^
/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
        uint64_t ri_phys_footprint;
        ^
/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_start_abstime;
        ^
/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t'
        uint64_t ri_proc_exit_abstime;
        ^
/usr/include/sys/resource.h:210:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t'
        uint64_t ri_user_time;
        ^
/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t'
        uint64_t ri_system_time;
        ^
/usr/include/sys/resource.h:213:2: error: unknown type name 'uint64_t'
        uint64_t ri_pkg_idle_wkups;
        ^
/usr/include/sys/resource.h:214:2: error: unknown type name 'uint64_t'
        uint64_t ri_interrupt_wkups;
        ^
/usr/include/sys/resource.h:215:2: error: unknown type name 'uint64_t'
        uint64_t ri_pageins;
        ^
/usr/include/sys/resource.h:216:2: error: unknown type name 'uint64_t'
        uint64_t ri_wired_size;
        ^
/usr/include/sys/resource.h:217:2: error: unknown type name 'uint64_t'
        uint64_t ri_resident_size;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

我尝试安装并重新安装我能想到的与该问题相关的所有内容,例如gcc, g++, cc, brew, Xcode,command-line-tools等等。我还尝试了以下页面上的所有建议:

  • 未知类型名称 uint8_t?
  • 在 Mac OS X Yosemite 10.10.1 上包含搜索路径
  • 由于未知类型名称“uint64_t”,Cythonizing 失败
  • 未知类型名称“uint8_t”,MinGW
  • JT Bullitt 非常全面的博客

还有更多,但这些总结得很好。所有解决方案均无效。

I think 最后一个有最可能的解决方案。 (如果您在页面上搜索“未知”,您将看到修复程序。)根据开发人员的说法:

修复:从“标题搜索路径”构建设置中删除 /opt/local/include/** 和 /opt/local/lib/** 。将它们替换为所需包含目录的更具体的路径。在我的特定情况下,这意味着用 /opt/local/include/glib-2.0 /opt/local/lib/glib-2.0/include /opt/local/include/ 替换它们。它又启动并运行了!

但是,我没有安装Xcode,我只安装了命令行开发者工具。因此,我没有一种简单的方法来访问“标题搜索路径”构建设置,因此我无法尝试他的解决方案。

我正在寻找解决此问题的方法,最好是不需要我安装整个操作系统的解决方案。或者,如果有人可以指导我找到构建设置文件,我将非常感激。


也许你可以尝试:

mv /usr/local/include /usr/local/include.old

then:

brew install llvm

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法编译任何C++程序;错误:未知类型名称“uint8_t” 的相关文章

随机推荐