前置任务
VSCode本身是一个编辑器,但由于其有强大的Extensions包,作为跨平台的IDE毫无问题!
- 安装cmaker
- 安装vscode
- 在左边栏Extensions中搜索“C/C++, C++ Intellisense,CMake,CMake Tools,CMake Tools Helper”并install
- 刚刚安装vscode可以安装chinese工具包这里不详细介绍。
.json(环境配置文件)以下是一些常见变量
${workspaceFolder} - the path of the folder opened in VS Code
${workspaceRootFolderName} - the name of the folder opened in VS Code without any slashes (/)
${file} - the current opened file
${relativeFile} - the current opened file relative to workspaceRoot
${fileBasename} - the current opened file’s basename
${fileBasenameNoExtension} - the current opened file’s basename with no file extension
${fileDirname} - the current opened file’s dirname
${fileExtname} - the current opened file’s extension
${cwd} - the task runner’s current working directory on startup
${lineNumber} - the current selected line number in the active file
${env:Path} - environment variables reference path
作者:忠烈
来源:CSDN
原文:https://blog.csdn.net/u010677365/article/details/80703984
版权声明:本文为博主原创文章,转载请附上博文链接!
launch.json
输出环境配置{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "g++ build and debug active file", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/wori", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "g++ build active file", "miDebuggerPath": "/usr/bin/gdb" } ] }
tasks.json
{
// 有关 tasks.json 格式的文档,请参见
// https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceRoot}/wori.cpp",
"-o",
"${workspaceRoot}/wori"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
]
}
]
}