c - 无法使用 mac os 不支持的体系结构编译简单的 c 代码

标签 c macos compiler-errors clang

代码是

#include <stdio.h>

int
main () {
    printf("Defined\n");
}

简单的代码是用

编译的
gcc test.c -o test

or 

clang test.c -o test

它抛出...

In file included from test.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/_stdio.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/sys/cdefs.h:784:2: error: Unsupported architecture
#error Unsupported architecture
 ^
In file included from test.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/sys/_types.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
 ^
In file included from test.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/_stdio.h:71:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/_types.h:27:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'; did
      you mean '__int128_t'?
typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
        ^
note: '__int128_t' declared here
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'; did
      you mean '__int128_t'?
typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
        ^
note: '__int128_t' declared here

还有更多类似的错误。

当然编译器之前可以正常工作,但是在我将 mac os 更新到 10.14.5 (18F132) 之后,它发生了。看起来编译器设置有一些问题,但我不知道从哪里开始。

我的 clang 版本是

Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

最佳答案

谢谢@robthebloke,

我重新安装了与 xcode 相关的所有内容,但它不起作用。我重新启动了 mac,以便重置环境变量并且它确实有效!

看起来我不小心触及了环境变量,但我无法确定到底是哪一个导致了问题。

仅供引用:我通常将一堆 c 代码编译到几个平台:mac os、android 和 ios。我想我的交叉编译脚本与更新的操作系统或编译器有问题(?)。

正如@Clifford 所说,printenv | grep iPhoneOS 可能会发现问题。

关于c - 无法使用 mac os 不支持的体系结构编译简单的 c 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57050529/

相关文章:

c - 快速反演算法比 math.h 1/sqrt 函数慢

c - 访问函数内的二维数组

macos - 如何删除 macOS SwiftUI 应用程序中的 "New window"选项?

macos - QTKit 在 mac os 中播放 protected 视频(HDCP)

c++ - 无法打开文件 'VCLE40.LIB' (C++ Builder)

c - 将主要参数传递给 gui 库的 init 函数

c++ - 如何使用 msgfmt 验证格式字符串中的位置符号占位符?

Swift NSCollectionView 从下到上的流程

c++ - 为什么此代码中存在转换错误?

perl - 草莓 Perl - 错误消息 : This package requires a C compiler