Я хочу добавить компилятор C ++ в мою визуальную студию на моей ма c, но произошли ошибки - PullRequest
0 голосов
/ 03 мая 2020

С этого сайта https://code.visualstudio.com/docs/cpp/config-clang-mac, я убедился, что мой Clang был установлен. Образ о clang был установлен с помощью терминала .

После того, как я создал файлы и вставил код, который я попросил вставить, это:

# 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 << " ";
    }
    cout << endl;
}

Затем я запустил код несколько раз, и ошибка показывает: «

[Running] cd "/Users/myname/projects/helloworld/" && g++ helloworld.cpp -o helloworld &&
"/Users/myname/projects/helloworld/"helloworld
helloworld.cpp:9:23: error: expected ';' at end of declaration
    vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
                      ^
                      ;
helloworld.cpp:11:29: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
    for (const string& word : msg)
                            ^
1 warning and 1 error generated.

[Done] exited with code=1 in 1.255 seconds

Да, я скачал расширение C / C ++ для VS и пытался найти ошибку везде в Google, но не смог найти решение.

...