mercredi 24 mai 2017

Compile error on vscode. type specifier is a C++11 extension

How can I compile with C++11 compatible mode on vscode?

test.cpp

#include <iostream>

using namespace std;

void print()
{
    int v[] = {0,1,2,3,4,5,6,7,8,9};
    for (auto x : v) {
        cout << x << '\n';
    }

    for (auto x : {10,21,32,43,54,65}) {
        cout << x << '\n';
    }
}

int main() {
    print();
}

tasks.json

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "args": ["-O2", "-g", "test.cpp"],
    "showOutput": "always"
}

Error

test.cpp:8:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
    for (auto x : v) {


Update 1

$ gcc -v
Configured with: --prefix=/Applications/http://ift.tt/1d5DwEL --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/http://ift.tt/1z8WHIF

Aucun commentaire:

Enregistrer un commentaire