我正在嘗試運行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 11到g 您的Makefile中的命令列選項。Visual Studio 默認使用最新的 C 標準。gcc 默認為最早的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/408698.html
標籤:
下一篇:從gcc編譯的匯編代碼未運行
