获取错误“char16_t和char32_t未声明”

我正在Linux上开发一个C ++程序。 海湾合作委员会的版本是4.5.1 20100924.我想在我的程序中使用std :: atomic_int。 我已经包括了primefaces头如下:

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> ,我会得到相同的错误。 头文件uchar.h和cuchar.h不在我的系统上。 我该如何解决编译错误?

先谢谢你。

编辑:

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

您似乎没有在您的编译器中启用C ++ 11支持,或者您使用了未声明这些新类型的编译器。

对于char16_tchar32_t ,你不需要额外的包含。


g ++ howto:

键入g++ --version 。 如果它至少是4.4,那么它支持新的字符串文字 。 如果不是的话:你需要一个更新的编译器版本。

然后,确保将--std=c++0x--std=c++11传递给编译器。