如何查看我的gcc版本?

Hei*_*Hei 4 c++ gcc g++4.8 centos7

In file included from /usr/include/c++/4.8.2/locale:41:0,
                 from /usr/include/c++/4.8.2/iomanip:43,
                 from [...omitted by myself as it is irrelevant]
/usr/include/c++/4.8.2/bits/locale_facets_nonio.h:59:39: error: ‘locale’ has not been declared
     struct __timepunct_cache : public locale::facet
Run Code Online (Sandbox Code Playgroud)

以上是我的构建日志中的第一个错误.

我没有尝试自己编译glibc/gcc,我通过yum安装它们.

我找到的一个可疑的事情是:

$ ll /usr/include/c++/
total 4
drwxr-xr-x. 12 root root 4096 Dec 17 14:16 4.8.2
lrwxrwxrwx   1 root root    5 Dec 17 14:16 4.8.5 -> 4.8.2
$
Run Code Online (Sandbox Code Playgroud)

yum只显示了1个版本的gcc:

$ yum info gcc-c++
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.uhost.hk
 * epel: mirrors.hustunique.com
 * extras: centos.uhost.hk
 * updates: centos.uhost.hk
Installed Packages
Name        : gcc-c++
Arch        : x86_64
Version     : 4.8.5
Release     : 4.el7
Size        : 16 M
Repo        : installed
From repo   : base
Summary     : C++ support for GCC
URL         : http://gcc.gnu.org
License     : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Description : This package adds C++ support to the GNU Compiler Collection.
            : It includes support for most of the current C++ specification,
            : including templates and exception handling.
Run Code Online (Sandbox Code Playgroud)

任何想法如何验证/usr/include/c++/4.8.2中的标题确实来自4.8.5包?

提前致谢.

PS我认为glibc可能无关紧要,但这里是信息:

$ ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 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.
Written by Roland McGrath and Ulrich Drepper.
Run Code Online (Sandbox Code Playgroud)

Jon*_*ely 6

4.8.2目录的符号链接无需担心,红帽企业Linux(以及CentOS)上的libstdc ++头文件是这样排列的.

gcc --version将告诉gcc您路径中可执行文件的版本.

rpm -q libstdc++-devel 将告诉您拥有C++标准库头文件的软件包的版本.

rpm -ql libstdc++-devel 将列出该软件包安装的文件,其中包含文件 /usr/include/c++/4.8.2

rpm --verify libstdc++-devel 将通过用其他东西替换它来检查你是否搞砸了C++标题.

该错误是更令人担心的,那意味着你搞乱的东西了.我的猜测就是它的from [...omitted by myself as it is irrelevant]部分,这实际上可能非常相关.std::locale应该声明<bits/locale_classes.h>之前包含的内容<bits/locale_facets_nonio.h>,所以如果没有声明我的猜测是你有一些标题定义_LOCALE_CLASSES_H并阻止标准库标题被读取.千万不能定义包括用下划线开始卫士,他们保留的名称.