我正在尝试调试main.cpp文件,该文件位于文件名中包含空格的文件夹“ Jim and the Skyscrapers”中。
错误消息显示为:
无法打开“ Jim”:找不到文件
这也使我可以选择创建“ Jim”文件。
仅当我将文件重命名为“ JimAndTheSkyscrapers”以使其没有任何空格时,调试过程才起作用。
我在launch.json和c_cpp_properties.json文件中引用路径的方式是使用环境变量:$ {workspaceFolder}。
作为调试器,我使用cygwin的gdb。
我认为问题是:要么调试器以不允许空格的方式解析文件路径,要么是vs代码问题。知道是哪一个会很有帮助。
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{"name": "OUTPUT_PATH", "value": "results.txt"}
],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/cygwin64/bin/gdb.exe",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}