代码是
#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/