Getting the error 'char16_t and char32_t undeclared'

I am developing a C ++ program on Linux. The gcc version is 4.5.1 20100924. I want to use std :: atomic_int in my program. I have included the atomic header as shown below:

include <atomic> 

When compiling the program, I get the following errors:

 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 

If I include <cstdint> , I get the same errors. The headers uchar.h and cuchar.h are not in my system. How can I solve compilation errors?

Thanks in advance.

+7
source share
2 answers

Edition:

I was wrong. just pass --std=c++0x to g ++ and that will do it.

+6
source

You do not seem to have C ++ 11 support enabled in your compiler, or you are using a compiler for which these new types are not declared.

For char16_t and char32_t you do not need to enable additional options.


g ++ howto:

Type g++ --version . If it is at least 4.4, then it supports new string literals . If not: you need a newer version of the compiler.

Then be sure to pass --std=c++0x or --std=c++11 compiler.

+7
source

All Articles