![](/img/trans.png)
[英]which version of g++ does Scons pick | unrecognized command line option “-std=c++11”
[英]G++ version and std option
我看到我的一个 makefile 并看到下面的命令。
g++-5 -std=c++11
据我了解, std 选项代表了这一点-
GCC 支持不同的 C++ 方言,对应于多个已发布的 ISO 标准。 可以使用 -std= 命令行选项选择它实现的标准。
g++ 命令中的 -5 是什么意思?
g++ 旁边的参数 -n 表示您要编译代码的 GNU C++ 编译器版本
-5
是实际 g++ 可执行文件名称的一部分。 名称的确切选择基本上取决于您的操作系统或发行版的维护者。 以这种方式命名可执行文件允许并行安装多个 GCC 版本,这一功能通常很有用,例如,如果您想将您的软件提供给各种用户并希望确保不同的编译器版本可以处理您的代码。 例如,在我目前看到的一个(稍旧的)盒子上
$ ls -l /usr/bin/g++*
lrwxrwxrwx 1 root root 7 Apr 8 2014 /usr/bin/g++ -> g++-4.8
-rwxr-xr-x 1 root root 259176 Mar 20 2014 /usr/bin/g++-4.4
-rwxr-xr-x 1 root root 775888 May 7 2016 /usr/bin/g++-4.8
$ /usr/bin/g++-4.4 --version
g++-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ /usr/bin/g++-4.8 --version
g++-4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
不同的编译器版本不仅对 C++ 标准特性有不同的支持,它们也可能有不同的错误或怪癖。
关于 GCC 对不同版本的 C++ 标准的支持,请参见https://gcc.gnu.org/projects/cxx-status.html 。 例如,一些 C++17 语言特性仅在 GCC 5.1 中引入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.