zoukankan      html  css  js  c++  java
  • Linux环境下Eclipse对C++新特性的支持设置

    Linux环境下Eclipse对C++新特性的支持设置

        今天写一个简单的关于C11中的array容器的测试程序如下,

    #include <iostream>
    #include <array>
    
    using namespace std;
    
    int main()
    {
    	std::array<int, 5> myarray = { 2, 16, 77, 34, 50 };
    
    	std::cout << "myarray contains:";
    	for (auto it = myarray.begin(); it != myarray.end(); ++it)
    	{
    		std::cout << ' ' << *it;
    	}
    
    	std::cout << '
    ';
    
    	return 0;
    }  
    

    Build的时候发现会报错,如下图,发现array竟然属于未定义。我的g++版本为4.8.2,在编译的时候需要加上一个-std=c++11的编译选项

    所以在Eclipse中设置一下编译选项

    右击项目 --> Properties --> C/C++ Build --> Setting --> GCC C++ Compiler --> Dialect --> Language standard

    选择C++11或者其他版本,重新build即可

  • 相关阅读:
    Task Schedule
    Number Game
    CDQ分治
    Friends and Subsequences
    HDU5266 pog loves szh III
    P1593 因子和
    求一个数的欧拉函数的优化
    Grandpa's Estate POJ
    LightOJ
    Paint The Wall HDU
  • 原文地址:https://www.cnblogs.com/SimonKly/p/7806787.html
Copyright © 2011-2022 走看看