zoukankan      html  css  js  c++  java
  • g++ 编译c++11选项

    https://askubuntu.com/questions/26498/choose-gcc-and-g-version

     264
    down vote
    favorite
    96

    I'm trying to update my C++ compiler to C++11. I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x or -std=gnu++0x, but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.)

    Here is the error that i get from the compiler when i attempt to use a library which is included in C++11(i.e. array):

    #include <array>
    #include <iostream>

    int main()
    {
        std::array<int, 3> arr = {2, 3, 5};
        ...
    }

    This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
    c++ c++11 g++ flags
    shareimprove this question
    edited Oct 26 '12 at 17:34
    asked Apr 28 '12 at 12:52
    Rontogiannis Aristofanis
    3,88962854

    show 3 more comments
    4 Answers
    active
    oldest
    votes
    up vote
    391
    down vote
    accepted

    Flags (or compiler options) are nothing but ordinary command line arguments passed to the compiler executable.

    Assuming you are invoking g++ from the command line (terminal):

    $ g++ -std=c++11 your_file.cpp -o your_program

    or

    $ g++ -std=c++0x your_file.cpp -o your_program

    if the above doesn't work.
    shareimprove this answer

  • 相关阅读:
    手风琴效果
    开关门
    常用的一些获取尺寸的方法
    话话js中的事件监听
    数组去重
    百度地图 之 热力图
    小程序 之 百度智能小程序(第二章)
    小程序 之 百度智能小程序(第一章)
    javascript 之 继承与闭包
    浅谈prototype与__proto__、constructor三者之间的关系
  • 原文地址:https://www.cnblogs.com/CreatorKou/p/8667341.html
Copyright © 2011-2022 走看看