如何和我在哪裏可以添加包括在下面的配置路徑?
該列表是一個逗號分隔列表,因此添加一個包含路徑看起來像是;
"configurations": [
{
"name": "Mac",
"includePath": ["/usr/local/include",
"/path/to/additional/includes",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include"
]
}
]
Source; cpptools blog 31 March 2016。
鏈接的源文件有一個顯示Win32配置格式的gif,但其他格式也適用。
如果安裝了Xcode,上述示例包含SDK(OSX 10.11)路徑。
注意我發現一旦包含路徑被更改可能需要一段時間才能更新。
cpptools擴展可以是found here。
有關VSCode中C++語言支持的其他文檔(來自Microsoft)可以是found here。
對於保存的緣故(從討論),下面是用於tasks.json文件的內容編譯和執行任一個C++文件,或C文件的基本片斷。它們允許文件名中有空格(需要使用\"
轉義json中的額外引號)。該shell使用as the runner,因此允許該程序的編譯(clang...
)和執行(&& ./a.out
)。它還假定tasks.json「存在於」本地工作空間(在.vscode目錄下)。進一步的task.json細節,比如支持的變量等可以是found here。
對於C++;
{
"version": "0.1.0",
"isShellCommand": true,
"taskName": "GenericBuild",
"showOutput": "always",
"command": "sh",
"suppressTaskName": false,
"args": ["-c", "clang++ -std=c++14 -Wall -Wextra -pedantic -pthread \"${file}\" && ./a.out"]
}
對於C;
{
"version": "0.1.0",
"isShellCommand": true,
"taskName": "GenericBuild",
"showOutput": "always",
"command": "sh",
"suppressTaskName": false,
"args": ["-c", "clang -std=c11 -Wall -Wextra -pedantic -pthread \"${file}\" && ./a.out"] // command arguments...
}
讓我們[在聊天中繼續討論](http://chat.stackoverflow.com/rooms/113606/discussion-between-niall-and-stdio-h)。 – Niall
@ stdio.h。我推薦一本關於C的好書,深入研究這門語言;在http://stackoverflow.com/q/562303/3747990上的SO上有一個列表。如果你有興趣,還有一個C++列表; http://stackoverflow.com/q/388242/3747990。這兩份名單都至少包含一本網上可用的書籍,可以幫助您掌握並運用這些書籍,併爲您在SO和其他教程網站上找到的許多其他材料提供了良好的背景。我喜歡這些列表,因爲它們是策劃列表,而不僅僅是隨機轉儲掉的互聯網。 – Niall
非常感謝您發佈此內容。節省我很多分鐘! – sivabudh