Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取错误';char16_t和char32_t未声明'; 我在Linux上开发了一个C++程序。gcc版本为4.5.1 20100924。我想在我的程序中使用std::atomic_int。我已包括如下原子标题: include <atomic>_C++_Linux_Gcc_G++_Std - Fatal编程技术网

获取错误';char16_t和char32_t未声明'; 我在Linux上开发了一个C++程序。gcc版本为4.5.1 20100924。我想在我的程序中使用std::atomic_int。我已包括如下原子标题: include <atomic>

获取错误';char16_t和char32_t未声明'; 我在Linux上开发了一个C++程序。gcc版本为4.5.1 20100924。我想在我的程序中使用std::atomic_int。我已包括如下原子标题: include <atomic>,c++,linux,gcc,g++,std,C++,Linux,Gcc,G++,Std,如果我包括,我会得到相同的错误。标题uchar.h和cuchar.h不在我的系统中。如何解决编译错误 提前谢谢。编辑: 我错了。只要将std=c++0x传递给g++,就可以了。您的编译器中似乎没有启用c++11支持,或者您使用的编译器没有声明这些新类型 对于char16\u t和char32\u t,您不需要额外的包含 g++如何: 键入g++--version。如果它至少是4.4,那么它支持。如果不是:您需要更新的编译器版本 然后,确保将--std=c++0x或--std=c++11传递给编

如果我包括
,我会得到相同的错误。标题uchar.h和cuchar.h不在我的系统中。如何解决编译错误


提前谢谢。

编辑:


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

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

对于
char16\u t
char32\u t
,您不需要额外的包含


g++如何:

键入
g++--version
。如果它至少是4.4,那么它支持。如果不是:您需要更新的编译器版本


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

是否传递选项
-std=c++0x
cuchar.h
不是头,只是
cuchar
。总之,
charXX\u t
是“内置”类型,不需要包含。将-std=c++0x传递给g++解决了这个问题。非常感谢。我还建议升级编译器;GCC的当前版本为4.7,4.6于2011年3月发布;既然你想要C++2011的功能,最好升级一下。@LokiAstari是的,这是真的。洛基:在我看来,标准将它们定义为关键字,不需要额外的包含
cuchar
没有定义类型/别名。@geekowl:几乎是咆哮:这个答案在最初只给出一些腐烂的鱼之后给出了一条鱼。另一个答案给出了鱼和一些关于如何钓鱼的信息。然而,另一个答案没有被接受。当你意识到自己错了而其他人是对的时候,你不应该删除你的答案吗?我认为chappjc是对的。把答案完全改成现有答案的调子是不好的
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