-std=c++11 not working with Sublime Text 2 on Mac

0

1

So, I installed gcc 4.7 with ports. Manually compiling my file with g++ file.cpp -o file It spots an error. By appending the -std=c++11 it works like a charm. Now I edited my C++.sublime-build:

{
    "cmd": ["g++", "-std=c++11", "${file}", "-o", "${file_path}/${file_base_name}"],
    "working_dir": "${file_path}",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}

It throws these strange errors:

/Users/magnus/Coding/Stuff/vector.cpp:6:14: error: no matching constructor for initialization of 'vector<int>'
        vector<int> numbers{1, 2, 3};
                    ^      ~~~~~~~~~
/usr/include/c++/4.2.1/bits/stl_vector.h:255:9: note: candidate constructor [with _InputIterator = int] not viable: no known conversion from 'int' to 'const allocator_type' (aka 'const std::allocator<int>') for 3rd argument
        vector(_InputIterator __first, _InputIterator __last,
        ^
/usr/include/c++/4.2.1/bits/stl_vector.h:213:7: note: candidate constructor not viable: no known conversion from 'int' to 'const allocator_type' (aka 'const std::allocator<int>') for 3rd argument
      vector(size_type __n, const value_type& __value = value_type(),
      ^
/usr/include/c++/4.2.1/bits/stl_vector.h:201:7: note: candidate constructor not viable: allows at most single argument '__a', but 3 arguments were provided
      vector(const allocator_type& __a = allocator_type())
      ^
/usr/include/c++/4.2.1/bits/stl_vector.h:231:7: note: candidate constructor not viable: requires single argument '__x', but 3 arguments were provided
      vector(const vector& __x)
      ^
1 error generated.
[Finished in 0.2s with exit code 1]

Why does it work in the terminal, but refuses to work in ST2?

Magnus

Posted 2013-10-16T12:51:19.030

Reputation: 103

I tried the exact same configuration in my Fedora machine and it worked... – Magnus – 2013-10-16T13:20:38.407

this might be better suited to StackOverflow, as SuperUser doesn't really do programming questions.

– MattDMo – 2013-10-17T18:03:57.640

How are you building? Did you accidentally use the Run variant? that one doesn't have your C++11 flag... – MattDMo – 2013-10-17T18:06:36.750

No answers