GDB中文文件名,路径调试问题
TAGS GDB;C++;Chinese
配置配置文件
tasks.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| { "tasks": [ { "type": "cppbuild", "label": "C/C++: g++.exe build active file", "command": "C:\\MinGW\\bin\\g++.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\\a.exe" ], "options": { "cwd": "C:\\MinGW\\bin" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "Generated task by Debugger" }, ], "version": "2.0.0" }
|
launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| { "version": "0.2.0", "configurations": [ { "name": "g++.exe - 生成和调试活动文件", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\a.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: g++.exe build active file" } ] }
|
参考文章链接:真正解决VScode C\C++中文名无法运行问题
评论区【zhaoxf4】说“思路不错,不过要注意tasks.json下的”type”的值应当是”shell”,如果填成”cppbuild”,仍然会生成原来文件名的.exe文件”
吾辈并未作更改,是可以编译中文文件名的,所以。。。
总结:
- 找到问题所在:GDB可以编译但无法调试。
- 尝试解决: 使GDB编译生成的文件为英文名
- 测试方案可行性
运用到了JSON的相关知识,本身难度不大。
VScode中启动的控制台闪退
TAGS C++;VScode
方案一
在 launch.json 加入如下代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| { "name": "(Windows) Launch", "type": "cppvsdbg", "request": "launch", "program": "C:\\Windows\\system32\\cmd.exe", "args": [ "/C", "${fileDirname}\\${fileBasenameNoExtension}.exe", "&", "pause" ], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true }
|
TAGS Chinese
总结:添加系统全局变量 PYTHONIOENCODING,值设置为 UTF8 然后再重启 VSCode 就好了。
Markdown预览格式错误