c++ - 获取错误 'char16_t and char32_t undeclared'

标签 c++ linux gcc g++ std

我正在 Linux 上用 C++ 开发一个程序。 gcc 版本是 4.5.1 20100924。我想在我的程序中使用 std::atomic_int。我包含了如下的原子 header :

include <atomic>

当我编译程序时出现以下错误:

In file included from /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomic_base.h:87:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/atomic:41,
                 from ../Source/Main.h:33:
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:107:25: error: ‘char16_t’ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:107:33: error: template argument 1 is invalid
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:107:53: error: invalid type in declaration before ‘;’ token
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:110:25: error: ‘char32_t’ was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:110:33: error: template argument 1 is invalid
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/atomicfwd_cxx.h:110:53: error: invalid type in declaration before ‘;’ token

如果我包括 <cstdint> ,我得到了同样的错误。 header uchar.h 和 cuchar.h 在我的系统上不存在。如何解决编译错误?

提前谢谢你。

最佳答案

已编辑:

我错了。只需将 --std=c++0x 传递给 g++,就可以了。

关于c++ - 获取错误 'char16_t and char32_t undeclared',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11741976/

相关文章:

c++ - << operator override 使用 g++ 而不是 Windows 编译

c - 为什么这个宏被定义为({ 1; })?

c - gcc 可能的错误?带有点符号的结构中缺少初始值设定项

c++ - 协变返回类型、常量和不完整类

c# - 如何获取有关设备驱动器的信息

c++ - 我可以使自己的自定义数据类型比 C++ 中的数据类型更大吗?

python - 在 SuSE 11.1 64 位上安装 yum

linux - 无法在Linux GUI上打开由cmake构建的Qt程序

c - ARM gcc 无法识别 CPU

linux - TLS 模型上的 GCC 通用变量属性