Reputation: 1043
I'm Following the Udacity´s C++ Nanodegree Program. For this course, the instructor uses VSCode, the C/C++ extension and the Clang-format.
According to the course instructions, I already installed the g++ compiler and the gdb debugger and both tools are working fine. the problem I´m having is that when I try to debug from VSC, I´m getting a completely different result from what tue instructor is showing. I'm using the following code
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
std::vector<std::string> brothers{"David", "Ethan", "Adam"};
for (std::string const &brother : brothers) {
std::cout << "Hello " << brother << "!\n";
}
}
And my debugging is showing some weird information.
which is different from what the instructor gets on his screen (he is on Linux). He is getting the actual content of the local variables.
This is the launch.json I'm using for the debugger
{
// 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++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"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"
}
]
}
I´m an intermediate python programmer just beginning with C++; My guess is that what my VSCode is showing is some memory allocation or type variable stuff, but that's not very usefull for software debuging. Does anybody knows how to configure VSCode or the compiler in order to show the content of the variables correctly? I'm using Windows.
Thanks!
uopdate:
here is my task.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file ver(1)",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: cpp.exe build active file",
"command": "C:\\MinGW\\bin\\cpp.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file ver(2)",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Upvotes: 4
Views: 1621
Reputation: 1043
I uninstalled minGW, installed the MinGW-w64 from this site http://mingw-w64.org/doku.php/download, changed MinGW environment variables, and problem solved!
Thanks!
Upvotes: 3