VSCode <error reading variable> 在调试期间查看数组元素时
VSCode <error reading variable> when viewing array elements during debugging
我正在调试 VSCode 中的以下代码:
int main() {
char arr1[] = {'t', 'e', 's', 't', '[=12=]'};
char arr2[] = "test";
int arr3[] = {1, 2, 3};
double arr4[] = {1.1, 2.2, 3.3};
}
前两个数组的元素显示为:
116 '<error reading variable>
101 '<error reading variable>
115 '<error reading variable>
116 '<error reading variable>
0 '<error reading variable>
而最后两个数组的元素显示数字的实际值。
launch.json
文件的内容是:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\MinGW\bin\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
怎样做才能让前两个数组显示数组中的字符?
以下 solution 解决了问题:
I found a workaround in this chinese blog
https://blog.csdn.net/m0_46304383/article/details/113487503
(translated with google transator). It seems a Windows 10 UTF-8
problem. I hope it can also help you @georgetian3.
The workaround is: "Windows Settings" -> "Time and Language" ->
"Region" -> "Other Date -> Time and Regional Settings" -> "Change Date
-> Time or Number Format" -> "Manage" -> "Change System Regional Settings" -> Uncheck "Beta version: Use Unicode UTF-8 to provide
global language support" -> restart the computer
我正在调试 VSCode 中的以下代码:
int main() {
char arr1[] = {'t', 'e', 's', 't', '[=12=]'};
char arr2[] = "test";
int arr3[] = {1, 2, 3};
double arr4[] = {1.1, 2.2, 3.3};
}
前两个数组的元素显示为:
116 '<error reading variable>
101 '<error reading variable>
115 '<error reading variable>
116 '<error reading variable>
0 '<error reading variable>
而最后两个数组的元素显示数字的实际值。
launch.json
文件的内容是:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\MinGW\bin\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
怎样做才能让前两个数组显示数组中的字符?
以下 solution 解决了问题:
I found a workaround in this chinese blog https://blog.csdn.net/m0_46304383/article/details/113487503 (translated with google transator). It seems a Windows 10 UTF-8 problem. I hope it can also help you @georgetian3.
The workaround is: "Windows Settings" -> "Time and Language" -> "Region" -> "Other Date -> Time and Regional Settings" -> "Change Date -> Time or Number Format" -> "Manage" -> "Change System Regional Settings" -> Uncheck "Beta version: Use Unicode UTF-8 to provide global language support" -> restart the computer