Ma c VSCode Debugger всегда показывает ошибку о ';' а также ':' - PullRequest
0 голосов
/ 02 апреля 2020

Я пытаюсь настроить среду vscode на моей Ma c. Я следую процедуре на сайте https://code.visualstudio.com/docs/cpp/config-clang-mac Но когда я пытаюсь отладить свою программу, она показывает ошибку и не может перешагнуть. Я не уверен, что это из-за версии или чего-то в этом роде.

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
vector<string> msg {"Hello", "C++++", "World", "from", "VS Code", "and the C++ extension!"};

for (const string& word : msg)
{
    cout << word << " ";
}

vector<string> aaa {"H", "E", "L", "L", "O"};
for (const string& word : aaa)
{
    cout << word << " ";
}


cout << endl;
}

И сообщение об ошибке показывает

ожидаемо; в конце декларации [9, 23] ожидаем; в конце объявления [16, 23] диапазон на основе l oop - расширение c ++ 11 [11, 29] диапазон на основе l oop - расширение c ++ 11 [17, 29]

Мой запуск. json файл

{
// 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": "(lldb) Launch",
        "name": "clang++ - Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [],
        "stopAtEntry": true,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "lldb",
        "preLaunchTask": "clang++ build active file"
    }
]
}

Моя задача. json файл

{
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "clang++ build active file",
        "command": "/usr/bin/clang++",
        "args": [
            "-std=c++17",
            "-stdlib=libc++",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

1 Ответ

0 голосов
/ 15 апреля 2020

ты заставил это работать? Я добавил c_cpp_properties. json в каталог .vscode со следующим:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
            ],
            "macFrameworkPath": [
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

и смог отладить тот же пример кода

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...