小编jim*_*mmy的帖子

每次我尝试使用 `clang -Weverything` 进行编译时,都会收到警告“包含位置 '/usr/local/include' 对于交叉编译来说是不安全的”

如果这个问题不清楚,我很抱歉,我什至很难开始调试这个问题。我在 macOS 上,每次使用标志编译 C 程序时都会收到以下错误/clang警告-Weverything and -Werror

error: include location '/usr/local/include' is unsafe for cross-compilation [-Werror,-Wpoison-system-directories]

最初我认为这是与我的代码相关的问题,但我发现现在我尝试编译的每个程序都会出现此错误。尽管总是使用这些标志进行编译,但我以前从未遇到过此错误,并且因为现在每个程序都会发生此错误,所以我怀疑它是我的编译器或系统更改的。我最近能想到的唯一改变是我在 VirtualBox 上使用 Lubuntu VM 创建了一些共享文件夹并更新了 Xcode。

我可以在没有标志的情况下编译程序-Weverything,并且它似乎按预期工作,但我想解决实际问题以继续使用-Weverything. 正如其他人以及这里的线程所提到的,在现实生活场景中使用-Weverything -Werror是过度的,但是,我主要将其用作学习工具,我想了解为什么即使对于像这样的基本程序也会出现这个问题helloworld.c(见下文) )。

我在这里遇到过一个讨论,但答案引用了一个configure.ac我不熟悉且不确定如何使用的文件。

如果我可以提供更多信息来帮助调试此问题,请告诉我。

作为示例,以下是以下结果cc -Weverything -Werror -v helloworld.c

Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.15.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name helloworld.c -mrelocation-model …
Run Code Online (Sandbox Code Playgroud)

c macos compiler-errors clang cross-compiling

8
推荐指数
1
解决办法
5394
查看次数

标签 统计

c ×1

clang ×1

compiler-errors ×1

cross-compiling ×1

macos ×1