﻿<?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>C++博客-小明思考-随笔分类-Tools</title><link>http://www.cppblog.com/sandy/category/1244.html</link><description>高性能服务器端计算</description><language>zh-cn</language><lastBuildDate>Sat, 27 Sep 2008 10:58:16 GMT</lastBuildDate><pubDate>Sat, 27 Sep 2008 10:58:16 GMT</pubDate><ttl>60</ttl><item><title>使用Gflags来检测heap问题</title><link>http://www.cppblog.com/sandy/archive/2008/09/27/62877.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Sat, 27 Sep 2008 02:59:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2008/09/27/62877.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/62877.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2008/09/27/62877.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/62877.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/62877.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 如何让char *p=new char[10];p[10]=10;报错？&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2008/09/27/62877.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/62877.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2008-09-27 10:59 <a href="http://www.cppblog.com/sandy/archive/2008/09/27/62877.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LeakDiag使用手记</title><link>http://www.cppblog.com/sandy/archive/2008/08/18/59260.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Mon, 18 Aug 2008 11:12:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2008/08/18/59260.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/59260.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2008/08/18/59260.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/59260.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/59260.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: LeakDiag是微软一款检测memory leak的工具&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2008/08/18/59260.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/59260.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2008-08-18 19:12 <a href="http://www.cppblog.com/sandy/archive/2008/08/18/59260.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>远程调试技术-使用vs2005</title><link>http://www.cppblog.com/sandy/archive/2008/07/28/57351.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Mon, 28 Jul 2008 07:20:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2008/07/28/57351.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/57351.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2008/07/28/57351.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/57351.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/57351.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 介绍远程调试技术&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2008/07/28/57351.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/57351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2008-07-28 15:20 <a href="http://www.cppblog.com/sandy/archive/2008/07/28/57351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VS2005 SP1的编译兼容性问题</title><link>http://www.cppblog.com/sandy/archive/2008/04/18/47519.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Fri, 18 Apr 2008 10:01:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2008/04/18/47519.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/47519.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2008/04/18/47519.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/47519.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/47519.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: VS2005 SP1的编译兼容性问题&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2008/04/18/47519.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/47519.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2008-04-18 18:01 <a href="http://www.cppblog.com/sandy/archive/2008/04/18/47519.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++源文件编码问题</title><link>http://www.cppblog.com/sandy/archive/2007/04/05/21320.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Thu, 05 Apr 2007 07:30:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2007/04/05/21320.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/21320.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2007/04/05/21320.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/21320.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/21320.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: C++源文件编码问题&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2007/04/05/21320.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/21320.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2007-04-05 15:30 <a href="http://www.cppblog.com/sandy/archive/2007/04/05/21320.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UltraEdit的一个Bug</title><link>http://www.cppblog.com/sandy/archive/2007/04/04/21231.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Wed, 04 Apr 2007 05:51:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2007/04/04/21231.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/21231.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2007/04/04/21231.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/21231.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/21231.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: UltraEdit的一个Bug&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2007/04/04/21231.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/21231.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2007-04-04 13:51 <a href="http://www.cppblog.com/sandy/archive/2007/04/04/21231.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WinDBG(CDB)实践1-新手指南</title><link>http://www.cppblog.com/sandy/archive/2007/03/13/19723.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Tue, 13 Mar 2007 06:39:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2007/03/13/19723.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/19723.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2007/03/13/19723.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/19723.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/19723.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Windbg(CDB) 新手指南&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2007/03/13/19723.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/19723.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2007-03-13 14:39 <a href="http://www.cppblog.com/sandy/archive/2007/03/13/19723.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>GDB 和 CDB 基本命令比较</title><link>http://www.cppblog.com/sandy/archive/2007/03/08/19425.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Thu, 08 Mar 2007 06:33:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2007/03/08/19425.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/19425.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2007/03/08/19425.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/19425.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/19425.html</trackback:ping><description><![CDATA[<p>也许有人不知道CDB是什么，CDB是windbg的小兄弟，基于command line,对于我这个比较喜欢用command line的人,CDB比windbg更容易上手。<br><br>象GDB,CDB这些工具，命令都很多，但是我们只要熟记最常用的"三板斧"就可以工作了。<br><br>1.启动<br>&nbsp;&nbsp;&nbsp;1)直接调试:&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>gdb program [core]</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>cdb program</strong> or <strong>cdb -z DumpFile</strong><br>&nbsp;&nbsp;&nbsp;2)attach方式<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>gdb attach pid</strong><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>cdb -pn ExeName</strong> or <strong>cdb -p pid<br></strong><br>2.显示堆栈<br>&nbsp;&nbsp;&nbsp;GDB: bt<br>&nbsp;&nbsp;&nbsp;CDB: k<br><br>3. 设置断点<br>&nbsp;&nbsp;&nbsp;GDB: b [file:]line<br>&nbsp;&nbsp;&nbsp;CDB: bp 'file:line'<br><br>4. 运行/继续运行<br>&nbsp;&nbsp; GDB: run [arglist]&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c&nbsp;&nbsp; 继续运行&nbsp;<br>&nbsp;&nbsp;&nbsp;CDB: g<br><br>5. 单步<br>&nbsp;&nbsp;&nbsp;GDB&nbsp;:&nbsp;n (step over) s (step into)<br>&nbsp;&nbsp;&nbsp;CDB : p<br><br>6.&nbsp;打印变量的值<br>&nbsp;&nbsp;&nbsp; GDB : p expr<br>&nbsp;&nbsp;&nbsp; CDB: ? expr<br><br>说老实话,CDB过于复杂，学起来比GDB难.</p>
<p>BTW:用CDB之前设置一下symbol的path<br>set _NT_SYMBOL_PATH=srv*c:\symbols*http://msdl.microsoft.com/download/symbols<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;</p><img src ="http://www.cppblog.com/sandy/aggbug/19425.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2007-03-08 14:33 <a href="http://www.cppblog.com/sandy/archive/2007/03/08/19425.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Tips]如何计算utf8下的字节数</title><link>http://www.cppblog.com/sandy/archive/2006/11/08/14841.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Wed, 08 Nov 2006 05:32:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/11/08/14841.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/14841.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/11/08/14841.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/14841.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/14841.html</trackback:ping><description><![CDATA[项目需要，写了一个帮助L10N的工程师计算utf8的小工具(html page)。如下<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">&lt;!</span><span style="COLOR: #ff00ff">DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">HTML</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">HEAD</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">TITLE</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"> An utf8 count tool  </span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">TITLE</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">meta </span><span style="COLOR: #ff0000">http-equiv</span><span style="COLOR: #0000ff">="Content-Type"</span><span style="COLOR: #ff0000"> content</span><span style="COLOR: #0000ff">="text/html; charset=utf16"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><br />    </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> utf16to8(str) {<br />        </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> out, i, len, c;<br /><br />        out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<br />        len </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> str.length;<br />        </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(i </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">; i </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> len; i</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) {<br />        c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> str.charCodeAt(i);<br />        </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x0001</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> (c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x007F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)) {<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> str.charAt(i);<br />        } </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">else</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> (c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x07FF</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) {<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> String.fromCharCode(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0xE0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">|</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">12</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x0F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">));<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> String.fromCharCode(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x80</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">|</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">  </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">6</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x3F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">));<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> String.fromCharCode(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x80</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">|</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">  </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x3F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">));<br />        } </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">else</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> {<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> String.fromCharCode(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0xC0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">|</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">  </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">6</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x1F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">));<br />            out </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> String.fromCharCode(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x80</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">|</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> ((c </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;&gt;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">  </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">) </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0x3F</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">));<br />        }<br />        }<br />        </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">return</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> out;<br />    }<br />    </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> count()<br />    {<br />        </span><span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> temp </span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> f1.value;<br />        temp</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">temp.replace(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">\\r</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">g,</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">\r</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br />        temp</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">temp.replace(</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">\\n</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">/</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">g,</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">\n</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<br />        result.innerHTML</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span><span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">utf16to8(temp).length;<br />    }<br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">script</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">HEAD</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">BODY</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">TEXTAREA </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="f1"</span><span style="COLOR: #ff0000"> NAME</span><span style="COLOR: #0000ff">="f1"</span><span style="COLOR: #ff0000"> ROWS</span><span style="COLOR: #0000ff">="10"</span><span style="COLOR: #ff0000"> COLS</span><span style="COLOR: #0000ff">="50"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">TEXTAREA</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">br</span><span style="COLOR: #0000ff">/&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">INPUT </span><span style="COLOR: #ff0000">TYPE</span><span style="COLOR: #0000ff">="button"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">="count length"</span><span style="COLOR: #ff0000"> onclick</span><span style="COLOR: #0000ff">="count()"</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">div </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="result"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">div</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">BODY</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">HTML</span><span style="COLOR: #0000ff">&gt;</span><span style="COLOR: #000000"><br /></span></div><img src ="http://www.cppblog.com/sandy/aggbug/14841.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-11-08 13:32 <a href="http://www.cppblog.com/sandy/archive/2006/11/08/14841.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Quick Reference -- 工程师必备</title><link>http://www.cppblog.com/sandy/archive/2006/09/28/13114.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Thu, 28 Sep 2006 07:30:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/09/28/13114.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/13114.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/09/28/13114.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/13114.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/13114.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 工程师必备&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2006/09/28/13114.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/13114.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-09-28 15:30 <a href="http://www.cppblog.com/sandy/archive/2006/09/28/13114.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Tips]如何识别字符编码</title><link>http://www.cppblog.com/sandy/archive/2006/09/27/13014.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Wed, 27 Sep 2006 02:00:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/09/27/13014.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/13014.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/09/27/13014.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/13014.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/13014.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 介绍识别字符编码的小技巧&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2006/09/27/13014.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/13014.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-09-27 10:00 <a href="http://www.cppblog.com/sandy/archive/2006/09/27/13014.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>代码格式化工具</title><link>http://www.cppblog.com/sandy/archive/2006/07/14/9855.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Fri, 14 Jul 2006 08:32:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/07/14/9855.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/9855.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/07/14/9855.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/9855.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/9855.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 介绍两个用于C/C++/Java格式化的工具&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2006/07/14/9855.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/9855.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-07-14 16:32 <a href="http://www.cppblog.com/sandy/archive/2006/07/14/9855.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++代码静态分析工具-Prefast</title><link>http://www.cppblog.com/sandy/archive/2006/03/28/4689.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Tue, 28 Mar 2006 05:59:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/03/28/4689.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/4689.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/03/28/4689.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/4689.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/4689.html</trackback:ping><description><![CDATA[<p>
				<strong>1. 什么是Prefast</strong>
				<br />
				<br />Prefast是一种代码分析工具，它能够帮助你找到编译器不能找到的错误或者缺陷。Prefast首次被微软集成到Visual Studio 2005 Team Suite中去，使用起来非常方便。<br /><br /><strong>2.怎么使用Prefast</strong><br />在vs2005 Team Suite中，使用Prefast非常简单。修改你的工程属性，设置Enable Code Analysis For C/C++为Yes.<br /><br /><img height="414" alt="prefast1.jpg" src="http://www.cppblog.com/images/cppblog_com/sandy/prefast1.jpg" width="594" border="0" /><br /><br />效果:<br /><img height="624" alt="prefast2.jpg" src="http://www.cppblog.com/images/cppblog_com/sandy/prefast2.jpg" width="896" border="0" /><br /><br />注意到有可能错误的地方以浅灰色显示在编辑器中了。</p>
		<p>
				<strong>3.Prefast能帮你找到哪些错误<br /></strong>
				<br />1)没有初始化</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">no initial</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect1()<br />{<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b;<br /><br />        b </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> a;<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(18) : warning C6001: Using uninitialized memory 'a': Lines: 15, 16, 18<br /><br />2)空指针取值<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">one path dereference NULL</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect4(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> c)<br />{<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">p </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> NULL;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (b </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">) {<br />                </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (c </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">) {<br />                        p </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">a;<br />                }<br />                </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />                                                <br />                }<br />        }<br />        </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />                </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (c </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">) {<br /><br />                }<br />                </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> {<br />                        p </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000">a;<br />                }<br />        }<br /><br />        </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">p;<br /><br />        </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000">;<br />}    <br /></span>
		</div>
		<p>会报:d:\test\testcode\testcode.cpp(65) : warning C6011: Dereferencing NULL pointer 'p': Lines: 45, 46, 48, 57, 65<br /><br />3)可能错误的运算符优先级<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect5()<br />{<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> b </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> c </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (a </span>
				<span style="COLOR: #000000">&amp;</span>
				<span style="COLOR: #000000"> b </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> c)<br />                </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000">;<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(76) : warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators<br /><br />4)可能的buffer overrun</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect8()<br />{<br />        </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> buf[</span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">];<br />        </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> buf2[</span>
				<span style="COLOR: #000000">200</span>
				<span style="COLOR: #000000">];<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">;<br /><br />        sprintf(buf, </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">hello world %d</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">, i);<br />        strcpy(buf, buf2);<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(133) : warning C6202: Buffer overrun for 'buf', which is possibly stack allocated, in call to 'strcpy': length '200' exceeds buffer size '100'<br /><br />5)可能的无穷循环<br /><br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">infinite loop</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect14()<br />{<br />        signed </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> i;<br /><br />        </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000"> (i </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">100</span>
				<span style="COLOR: #000000">; i </span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">; i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">) {<br />                ; <br />        }<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(198) : warning C6292: Ill-defined for-loop: counts up from maximum<br /><br />6)格式字符串错误<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">Format string mismatch</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect21()<br />{<br />        </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> buff[</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">];<br />        sprintf(buff, </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">%s %s</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">a</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(277) : warning C6063: Missing string argument to 'sprintf' that corresponds to conversion specifier '2'<br /><br />7)安全问题<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect27()<br />{<br />        CreateProcess(NULL,<br />               </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">c:\\program files\\Project.exe arg1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">, </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">correct "\"c:\\program files\\Project.exe\" arg1",</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">               NULL,<br />               NULL,<br />               </span>
				<span style="COLOR: #0000ff">false</span>
				<span style="COLOR: #000000">,<br />               </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,<br />               NULL,<br />               NULL,<br />               NULL,<br />               NULL);               <br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(327) : warning C6277: NULL application name with an unquoted path in call to 'CreateProcessA': results in a security vulnerability if the path contains spaces<br /><br />8)=和==误用<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect32()<br />{<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> a </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (a </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">)<br />                </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000">;<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(405) : warning C6282: Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead<br /><br />9)逻辑运算问题<br /></p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">always false</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> defect45()<br />{<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> x;<br /><br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&amp;&amp;</span>
				<span style="COLOR: #000000"> x</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">) {<br />                ;<br />        }<br />}</span>
		</div>
		<p>会报: d:\test\testcode\testcode.cpp(564) : warning C6237: (&lt;zero&gt; &amp;&amp; &lt;expression&gt;) is always zero. &lt;expression&gt; is never evaluated and might have side effects<br /><br />10)其他<br /><br /><br /><br /><br /><br /></p><img src ="http://www.cppblog.com/sandy/aggbug/4689.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-03-28 13:59 <a href="http://www.cppblog.com/sandy/archive/2006/03/28/4689.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C++跨平台开发方法/工具</title><link>http://www.cppblog.com/sandy/archive/2006/03/24/4544.html</link><dc:creator>小明</dc:creator><author>小明</author><pubDate>Fri, 24 Mar 2006 08:45:00 GMT</pubDate><guid>http://www.cppblog.com/sandy/archive/2006/03/24/4544.html</guid><wfw:comment>http://www.cppblog.com/sandy/comments/4544.html</wfw:comment><comments>http://www.cppblog.com/sandy/archive/2006/03/24/4544.html#Feedback</comments><slash:comments>15</slash:comments><wfw:commentRss>http://www.cppblog.com/sandy/comments/commentRss/4544.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/sandy/services/trackbacks/4544.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 主要阐述linux/windows跨平台开发<br>&nbsp;&nbsp;<a href='http://www.cppblog.com/sandy/archive/2006/03/24/4544.html'>阅读全文</a><img src ="http://www.cppblog.com/sandy/aggbug/4544.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/sandy/" target="_blank">小明</a> 2006-03-24 16:45 <a href="http://www.cppblog.com/sandy/archive/2006/03/24/4544.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>