-std=c++11 在 Mac 上无法与 Sublime Text 2 配合使用

-std=c++11 在 Mac 上无法与 Sublime Text 2 配合使用

因此,我安装了带有 ports 的 gcc 4.7。手动编译我的文件时, g++ file.cpp -o file 它发现了一个错误。通过附加,-std=c++11它就像魔法一样工作。现在我编辑了我的 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}'"]
        }
    ]
}

它抛出了这些奇怪的错误:

/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]

为什么它在终端中可以工作,但在ST2中却拒绝工作?

相关内容