P
P
Pychev Anatoly2018-11-17 00:04:08
Visual Studio Code
Pychev Anatoly, 2018-11-17 00:04:08

How to write task.json to compile C++ file?

Hello.
Please tell me where I have an error
wrote a simple code on cpp

#include <iostream>
using namespace std;
int main() {
  //setlocale(LC_ALL, "");
int ans, x, y;
  bool f;
    std::cout << "hello!" << endl;
  cout <<" -------------------------" << endl;

return 0;
}

As stated in the VS Code documentation compiled a simple launch.json
launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "preLaunchTask": "mybuild",
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}

and
task.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "mybuild",
            "type": "shell",
            "command": "g++",
            "args": [
                "${file}",
                "-g"
                  ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "always"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

Gives an error on startup
Invalid parameter format: /d

xkwdplbihewb3xxkza7utyimb5k.png
The MinGW64 compiler is installed, the path is registered in the PATH variable. Through the usual windows console, the file is compiled.
How to start compiling and debugging, where is the error?
Yes, I also read everything that google gave me, tried it, the error is the same.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MrPopter, 2019-09-24
@MrPopter

Did you manage to find a solution? The situation is the same and I can't find anything similar.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question