﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-闲云流水的点点滴滴-文章分类-技术</title><link>http://www.cnitblog.com/cqshen/category/6231.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Sep 2011 04:22:12 GMT</lastBuildDate><pubDate>Tue, 27 Sep 2011 04:22:12 GMT</pubDate><ttl>60</ttl><item><title>char是表示unsigned char 还是signed char?</title><link>http://www.cnitblog.com/cqshen/articles/34015.html</link><dc:creator>闲云流水</dc:creator><author>闲云流水</author><pubDate>Tue, 25 Sep 2007 10:06:00 GMT</pubDate><guid>http://www.cnitblog.com/cqshen/articles/34015.html</guid><wfw:comment>http://www.cnitblog.com/cqshen/comments/34015.html</wfw:comment><comments>http://www.cnitblog.com/cqshen/articles/34015.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/cqshen/comments/commentRss/34015.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/cqshen/services/trackbacks/34015.html</trackback:ping><description><![CDATA[ 最近在工作遇到一个问题，使用了一个WE_SINT8,WE_SINT8是如下定义的typedef char WE_SINT8,当我给定义为WE_SINT8的变量赋负-1时，发现值变成了255。后来发现原来编译器把char 当作了unsigned char.呵呵，以前的经验一般把char默认当作signed char的。后来查了google.原来编译器有个开关的 -funsigned-char就把char当作unsiged char,如果带上-fsigned-char就会把char当作signed char.
  绝大多数系统，包括x86 GNU/Linux and Microsoft Windows,都把char当作singed char,而PowerPC and ARM processors会默认当作unsigned char.
   以后还是明确点。要不signed char ，要不unsigned char. char要少写，这样以后移植工作就会顺利很多。

  我有一个疑问，为啥char可以有编译器来指定是 signed char还是unsigned char,为啥short和int都默认为signed short和singed int.没有编译器开关来设定呢？？？？ <img src ="http://www.cnitblog.com/cqshen/aggbug/34015.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/cqshen/" target="_blank">闲云流水</a> 2007-09-25 18:06 <a href="http://www.cnitblog.com/cqshen/articles/34015.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>