拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 macOS:C 11编译错误,Appleclang版本13在终端中但在Xcode中没有

macOS:C 11编译错误,Appleclang版本13在终端中但在Xcode中没有

白鹭 - 2022-01-23 2310 0 0

我正在尝试运行Microsoft Docs 中关于在 C 中委派建构式的示例对于像这样的一小段代码,我喜欢使用 VS Code,但是当我make在终端中使用我常用的命令时,我得到了错误,

error: delegating constructors are permitted only in C 11

当我在 Xcode 中运行相同的代码时,我没有收到此错误。

为什么我不能在终端中运行它?我的 Xcode 东西,包括命令列工具,都是最新的,所以我还缺少其他东西吗?

编辑

如果我进入g --version我得到的终端,

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c  /4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

uj5u.com热心网友回复:

您需要添加--std=c 11g 您的Makefile中的命令列选项。Visual Studio 默认使用最新的 C 标准。gcc 默认为最早的。

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *