Compile c++14-code with g++

前端 未结 4 1359
执笔经年
执笔经年 2020-12-02 16:35

I\'m using g++ 4.8.4 on Ubuntu 14.04 LTS. When trying to compile with \'-std=c++14\', I get this error:

g++: error unrecognized command line option \'-std=c+         


        
4条回答
  •  感动是毒
    2020-12-02 17:22

    For gcc 4.8.4 you need to use -std=c++1y in later versions, looks like starting with 5.2 you can use -std=c++14.

    If we look at the gcc online documents we can find the manuals for each version of gcc and we can see by going to Dialect options for 4.9.3 under the GCC 4.9.3 manual it says:

    ‘c++1y’

    The next revision of the ISO C++ standard, tentatively planned for 2014. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.

    So up till 4.9.3 you had to use -std=c++1y while the gcc 5.2 options say:

    ‘c++14’ ‘c++1y’

    The 2014 ISO C++ standard plus amendments. The name ‘c++1y’ is deprecated.

    It is not clear to me why this is listed under Options Controlling C Dialect but that is how the documents are currently organized.

提交回复
热议问题