簡體   English   中英

得到錯誤'char16_t和char32_t未聲明'

[英]Getting error 'char16_t and char32_t undeclared'

我正在Linux上用C ++開發一個程序。 gcc版本是4.5.1 20100924.我想在我的程序中使用std :: atomic_int。 我已經包含了原子頭如下:

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傳遞給編譯器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM