- 一个文件:
1 直接clang -o hello hello.c 编译, 2 然后debug那里建立launch.json -> lab1 -> c++.. -> GDB.. -> clang 3 注意必须在hello.cpp页面进行操作,因为参数有${fileDirname}这种,就是当前文件
- 多个文件: 要调整tasks.json
launch.json最后一行 “preLaunchTask”: “C/C++: clang build active file”, 这个 prelaunchtask需要调整,方法是自己建一个tasks.json
1 main menu, choose Terminal > Configure Default Build Task
2 Choose C/C++ clang++ build active file 建立tasks.json,
里面有"label": "C/C++: clang build active file",就是改这个了
3 args参数中"${file}"是当前文件,后面再加上其他cpp文件,比如"list.c",
3 press ⇧⌘B or from the Terminal main menu choose Run Build Task,编译当前文件
4 还是建立launch.json,不用改什么
https://code.visualstudio.com/docs/cpp/config-clang-mac#_reusing-your-c-configuration
- 查看vscode变量:
create a VSCode task to output the variable value to the console. For example, to see the resolved value for ${workspaceFolder}, you can create and run (Terminal > Run Task) the following simple ‘echo’ task in tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo ${workspaceFolder}"
}
]
}
https://code.visualstudio.com/docs/editor/variables-reference