Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/C++ extension cant evoke an "externalConsole". #48

Closed
ccybnumath opened this issue May 3, 2019 · 2 comments
Closed

C/C++ extension cant evoke an "externalConsole". #48

ccybnumath opened this issue May 3, 2019 · 2 comments
Assignees

Comments

@ccybnumath
Copy link

ccybnumath commented May 3, 2019

When "externalConsole" in launch.json is set false, everythig is just ok.
When set true, nothing happened.

  1. cpp configuration:
  • c_cpp_properties.json
{
    "configurations": [
        {
            "name": "WSL",
            "intelliSenseMode": "clang-x64",
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=7",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],            
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}
  • tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile",
            "command": "g++",
            "args": [
                "-g",
                "${file}",                    
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.out",
                "-ggdb3",
                "-Wall",
                "-static-libgcc",
                "-std=c++17",
                "-Wno-format",
                "-finput-charset=UTF-8",
                "-fexec-charset=UTF-8"
            ],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "\\"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        }
    ]
}
  • launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (GDB)",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${fileDirname}/${fileBasenameNoExtension}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "externalConsole": false,
            "internalConsoleOptions": "neverOpen",
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for GDB",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
            "preLaunchTask": "Compile"
        }
    ]
}
  1. cpp
#include <chrono>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int k, N = 3;
    double sum = 0;
    for (k = 0; k < N; k++)
    {
        auto t1 = chrono::high_resolution_clock::now();
        //do something.

        vector<int> vInt;
        constexpr int vSize = 1000000;
        int i;
        for (i = 0; i < vSize; i++)
            vInt.push_back(i);

        //end.
        auto t2 = chrono::high_resolution_clock::now();
        chrono::duration<double, std::milli> fp_ms = t2 - t1;
        sum += fp_ms.count();
        cout << "[" << k + 1 << "]"
             << "The elapsed time is " << fp_ms.count() << " milliseconds." << std::endl;
    }
    cout << "The average elapsed time is " << sum / N << " milliseconds." << std::endl;
    // system("pause");
    return 0;
}
@therealkenc
Copy link

therealkenc commented May 3, 2019

When set true, nothing happened.

Possibly variation Microsoft/vscode#67296 and Microsoft/vscode-cpptools#2998. I was able to start up vscode-cpptools debugging with "externalConsole=true" (ref #45). It works alright. However, it will only work if your remote side is set up so the external console can be launched on that side of the fence.

If something goes wrong, and the terminal can't be launched, then there isn't any feedback and it looks like "nothing happened" because vscode doesn't report any error (the symptom is usually the red debugging stop button lights up and then... nothing). Something is going to go "wrong" somewhat commonly, because the remote side isn't necessarily capable of launching a console.

Regardless of whether the behavior changes per #45 it would be nice if there was some glaring error when the external console fails to spawn for whatever reason (including locally).

@ccybnumath
Copy link
Author

@therealkenc oh, than you! I can figure out that.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants