wchar_t 2字节?4字节?在线

NightWolf 2006-09-08 09:05:41
今天郁闷至极,记得wchar_t 应该是2字节,但是我的编译器用sizeof(wchar_t)出来的是4。
不知那里的问题。搞的我以为wsccmp函数错了,花了一天的时间。
在gcc中,wchar_t因该是几字节的?或者编译开关如何设定?
在线等待
...全文
608 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hailongchang 2006-09-11
  • 打赏
  • 举报
回复
在GCC上就是4个字节,具体是两个字节还是四个字节是跟编译器相关的,在windows下是两个bytes,

以下文字摘自: What size wchar_t do I need for Unicode?
http://icu.sourceforge.net/docs/papers/unicode_wchar_t.html

The C standard does not specify the exact type for wchar_t. It is compiler dependent and may be 8, 16, or 32 bits wide (on modern machines), signed or unsigned. The choice depends on what encodings are expected to be processed on a particular platform. The standard also does not specify the representation of a multibyte code point with a wchar_t value: it is encoding- and library-dependent (except that a single-byte code point must have the same integer value in char and wchar_t types).
amingo 2006-09-10
  • 打赏
  • 举报
回复
帮LZ顶 LZ加油
fytzzh 2006-09-08
  • 打赏
  • 举报
回复
32位系统
Linux localhost.localdomain 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux

sizeof wchar_t = 4
yjf7888 2006-09-08
  • 打赏
  • 举报
回复
有2字节有4字节的

23,215

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧