简体   繁体   English

如何在NetBeans 8.1中正确配置g ++编译器以获得c ++ 11 / c ++ 14支持?

[英]How to configure g++ compiler in netbeans 8.1 correctly for c++11/c++14 support?

I'm a novice and work my way through Programming Principles and Practise using c++ by stroustrup ... I'm using Netbeans ide 8.1 and have a problem with the following: 我是新手,请通过stroustrup使用c ++进行编程原理和实践,以自己的方式工作。我使用的是Netbeans ide 8.1,并且存在以下问题:

#include "std_lib_facilities.h"
int main()
{
vector<int> v = {0,1,2,3,4,5,6};
for(int i = 0; i < v.size(); ++i)
    cout << v[i] << "\n";
}

If I compile, I get the error could not convert {0, 1, 2, 3, 4, 5, 6} from <brace-enclosed initializer list> to Vector<int> . 如果编译,我得到的错误是无法将{0, 1, 2, 3, 4, 5, 6}<brace-enclosed initializer list>Vector<int> I thought this has maybe something to do with missing compiler support for c++11 or 14, my compiler is g++ 4.8 . 我认为这可能与缺少对c++11或14的编译器支持有关,我的compilerg++ 4.8 Do I have to add anything to the compiler settings or is it another problem? 我是否必须在compiler设置中添加任何内容,还是另一个问题? Thanks 谢谢

确保您使用的是版本的"std_lib_facilities.h"而不是版本。

为c ++ 14添加编译器标志-std = c ++ 14,为c ++ 11添加同样的-std = c ++ 11。仅将这些标志之一添加到IDE中的build标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM