We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Runner 插件默认情况下的编译选项没有设置 C++ 标准,需要自己添加。
各系统的插件目录为:
%USERPROFILE%\.vscode\extensions
~/.vscode/extensions
其中 %USERPROFILE% 是 Windows 系统对应用户的文件夹,一般为 C:\Users\用户名。
%USERPROFILE%
C:\Users\用户名
在插件目录下 formulahendry.code-runner-0.9.17 的文件夹中(后面版本号可能有所不同)打开 package.json 文件,在第 $125$ 行(不同版本可能有所区别)中有如下语句:
formulahendry.code-runner-0.9.17
package.json
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
将其修改为:
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++14 && $dir$fileNameWithoutExt",
其中 -std=c++14 可以根据自己需求改为其他 C++ 标准。
-std=c++14
然后重启 VSCode 或者根据扩展程序已被修改的提示点击重新加载窗口,即可完成和应用配置修改。
在 launch.json 配置文件中需要添加调试前的 Task:
launch.json
Task
"preLaunchTask": "build"
后面的 build 对应为 tasks.json 中的编译任务的 label 属性。
build
tasks.json
label
在 tasks.json 中如需更改调试时编译选项,比如 C++ 标准或者栈空间等等,可以修改 args 属性:
args
"args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "-std=c++14", "-Wl,--stack=1024000000" ]
更多的选项,只需要在对应位置增加一行插入即可。
对于无法打开编译错误或警告中的文件时,如果发现其目录中有一段出现了两遍,可以选择修改 tasks.json 文件中 problemMatcher 属性:
problemMatcher
"problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "\\" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } }
或将下面序号全部加 $1$,上面配置按原有配置。
如果调试过程中出现了无法输入的现象,可以修改 launch.json 文件中 externalConsole 的属性:
externalConsole
"externalConsole": true
如果调试过程中输入前总是需要先选择继续,可以修改 launch.json 文件中 stopAtEntry 的属性:
stopAtEntry
"stopAtEntry": false
注意上述修改后,各属性之间需要以 , 分割,也就是说,除非是最后一项属性,末尾都需要注意添加 ,。
,
The text was updated successfully, but these errors were encountered:
Mac OS Catalina 下的 VSCode / LLDB 用户: 目前 VSCode 的 C++ 拓展尚未和 Catalina 下的 LLDB 适配,参见这条 issue。现在可以考虑安装 CodeLLDB 扩展解决问题,可能需要特殊的上网方式加快下载。
VSCode
C++
Catalina
LLDB
Sorry, something went wrong.
VSCode 显示 Unable to start debugging. Unable to establish a connection to GDB...:
如果你在 Windows 下,这可能是因为 PowerShell 启动太慢导致 VSCode 以为无法连接 GDB,参见这条 issue。可以通过将设置中的 terminal.integrated.shell.windows 改为 C:\Windows\System32\cmd.exe 使用 cmd 来避免这个问题(注意可能需要转义反斜杠)。
PowerShell
GDB
terminal.integrated.shell.windows
C:\Windows\System32\cmd.exe
cmd
由于预览版本已经修复这个问题,明年的同学可能不会受到影响。
现已修复于0.27.0
No branches or pull requests
Code Runner 插件配置修改
Code Runner 插件默认情况下的编译选项没有设置 C++ 标准,需要自己添加。
各系统的插件目录为:
%USERPROFILE%\.vscode\extensions
;~/.vscode/extensions
。其中
%USERPROFILE%
是 Windows 系统对应用户的文件夹,一般为C:\Users\用户名
。在插件目录下$125$ 行(不同版本可能有所区别)中有如下语句:
formulahendry.code-runner-0.9.17
的文件夹中(后面版本号可能有所不同)打开package.json
文件,在第将其修改为:
其中
-std=c++14
可以根据自己需求改为其他 C++ 标准。然后重启 VSCode 或者根据扩展程序已被修改的提示点击重新加载窗口,即可完成和应用配置修改。
Windows 系统下调试配置
在
launch.json
配置文件中需要添加调试前的Task
:后面的
build
对应为tasks.json
中的编译任务的label
属性。在
tasks.json
中如需更改调试时编译选项,比如 C++ 标准或者栈空间等等,可以修改args
属性:更多的选项,只需要在对应位置增加一行插入即可。
对于无法打开编译错误或警告中的文件时,如果发现其目录中有一段出现了两遍,可以选择修改
tasks.json
文件中problemMatcher
属性:或将下面序号全部加$1$ ,上面配置按原有配置。
如果调试过程中出现了无法输入的现象,可以修改
launch.json
文件中externalConsole
的属性:如果调试过程中输入前总是需要先选择继续,可以修改
launch.json
文件中stopAtEntry
的属性:注意上述修改后,各属性之间需要以
,
分割,也就是说,除非是最后一项属性,末尾都需要注意添加,
。The text was updated successfully, but these errors were encountered: