﻿<?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++博客-ngaut-随笔分类-c/c++/ds</title><link>http://www.cppblog.com/ngaut/category/635.html</link><description>asm/c/c++/......</description><language>zh-cn</language><lastBuildDate>Wed, 08 Sep 2010 12:01:56 GMT</lastBuildDate><pubDate>Wed, 08 Sep 2010 12:01:56 GMT</pubDate><ttl>60</ttl><item><title>ndis笔记--ReceiveHandler如何处理不完整的包</title><link>http://www.cppblog.com/ngaut/archive/2010/09/08/126145.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Wed, 08 Sep 2010 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2010/09/08/126145.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/126145.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2010/09/08/126145.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/126145.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/126145.html</trackback:ping><description><![CDATA[
代码参考aoe&nbsp;<div><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">#define</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> htons(x) (USHORT)((((x) &lt;&lt; 8) &amp; 0xff00) | (((x) &gt;&gt; 8) &amp; 0xff))</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">#define</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> ntohs(x) (USHORT)((((x) &lt;&lt; 8) &amp; 0xff00) | (((x) &gt;&gt; 8) &amp; 0xff))</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">#define</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> AOEPROTOCOLID 0x88a2</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">

VOID ProtocolTransferDataComplete(IN NDIS_HANDLE ProtocolBindingContext, 
                                          IN PNDIS_PACKET Packet, 
                                          IN NDIS_STATUS Status, 
                                          IN UINT BytesTransferred) {
    PNDIS_BUFFER Buffer;
    UINT HeaderSize, DataSize;
    PUCHAR Data </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL;
    PEH_HEADER Header </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL;
    

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">通过包描述符的NDIS_BUFFER链表的表头取得包的剩余部分的NDIS_BUFFER描述符, 见ProtocolReceive函数</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisUnchainBufferAtFront(Packet, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Buffer);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Buffer </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) {
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">得到包的剩余部分的内存地址和大小</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        NdisQueryBuffer(Buffer, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Data, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">DataSize);
        NdisFreeBuffer(Buffer);
    } </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> {
        DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolTransferDataComplete Data (front) Buffer == NULL\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">));
    }
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">通过包描述符的NDIS_BUFFER链表的表尾取得包的剩余部分的NDIS_BUFFER描述符, 见ProtocolReceive函数</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisUnchainBufferAtBack(Packet, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Buffer);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Buffer </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) {
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(128, 128, 128); ">///</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">/得到包头的内存地址和大小</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(128, 128, 128); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        NdisQueryBuffer(Buffer, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Header, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">HeaderSize);
        NdisFreeBuffer(Buffer);
    } </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">else</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> {
        DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolTransferDataComplete Header (back) Buffer == NULL\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">));
    }
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Header </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> Data </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) 
    {
            DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">完整包大小为%d</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">, HeaderSize </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">+</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> DataSize));
    }
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">AoEReply(Header-&gt;SourceMac, Header-&gt;DestinationMac, Data, DataSize);</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Header </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) 
        ExFreePool(Header);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Data </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) 
        ExFreePool(Data);
    NdisFreePacket(Packet);
}

NDIS_STATUS  ProtocolReceive(IN NDIS_HANDLE ProtocolBindingContext, 
                                    IN NDIS_HANDLE MacReceiveContext, 
                                    IN PVOID HeaderBuffer, 
                                    IN UINT HeaderBufferSize, 
                                    IN PVOID LookAheadBuffer, 
                                    IN UINT LookaheadBufferSize, 
                                    IN UINT PacketSize) {
    PADAPTER Context </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (PADAPTER)ProtocolBindingContext;
    NDIS_STATUS Status;
    PNDIS_PACKET Packet;
    PNDIS_BUFFER Buffer;
    PEH_HEADER Header;
    PUCHAR HeaderCopy, Data;
    UINT BytesTransferred;

    DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">));


    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (HeaderBufferSize </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">sizeof</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">(ETH_HEADER)) {
        DbgPrint(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive HeaderBufferSize %d != sizeof(HEADER) %d\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }
    Header </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (PEH_HEADER)HeaderBuffer;
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">/*</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
    if (ntohs(Header-&gt;EthType) != AOEPROTOCOLID) 
        return NDIS_STATUS_NOT_ACCEPTED;
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">*/</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (LookaheadBufferSize </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">==</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> PacketSize) {
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">AoEReply(Header-&gt;SourceMac, Header-&gt;DestinationMac, LookAheadBuffer, PacketSize);</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_SUCCESS;
    }

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">不完整的包</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">不完整的包</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">));

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">分配内存把包头保存包头</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> ((HeaderCopy </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (PUCHAR)ExAllocatePool(NonPagedPool, HeaderBufferSize)) </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">==</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) {
        DbgPrint(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive ExAllocatePool HeaderCopy\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }
    RtlCopyMemory(HeaderCopy, HeaderBuffer, HeaderBufferSize);

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">分配内存保存包的剩余部分</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> ((Data </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (PUCHAR)ExAllocatePool(NonPagedPool, PacketSize)) </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">==</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NULL) {
        DbgPrint(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive ExAllocatePool HeaderData\\n</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">);
        ExFreePool(HeaderCopy);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">分配一个包描述符</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisAllocatePacket(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Status, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Packet, Context</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">-&gt;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">RecvPacketPoolHandle);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">NT_SUCCESS(Status)) {
        DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive NdisAllocatePacket</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">, Status));
        ExFreePool(Data);
        ExFreePool(HeaderCopy);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">分配一个NDIS_BUFFER描述符，关联内存Data</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisAllocateBuffer(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Status, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Buffer, Context</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">-&gt;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">RecvBufferPool, Data, PacketSize);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">NT_SUCCESS(Status)) {
        DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive NdisAllocateBuffer (Data)</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">, Status));
        NdisFreePacket(Packet);
        ExFreePool(Data);
        ExFreePool(HeaderCopy);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">即将这个NDIS_BUFFER放到包描述符的NDIS_BUFFER链表的表头</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisChainBufferAtFront(Packet, Buffer);

    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">在分配一个NDIS_BUFFER描述符，关联内存HeaderCopy</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisAllocateBuffer(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Status, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Buffer, Context</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">-&gt;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">RecvBufferPool, HeaderCopy, PacketSize);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">NT_SUCCESS(Status)) {
        DBGPRINT((</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">ProtocolReceive NdisAllocateBuffer (HeaderCopy)</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">"</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">, Status));
        NdisUnchainBufferAtFront(Packet, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Buffer);
        NdisFreeBuffer(Buffer);
        NdisFreePacket(Packet);
        ExFreePool(Data);
        ExFreePool(HeaderCopy);
        </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_NOT_ACCEPTED;
    }
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">//</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">将描述包头的NDIS_BUFFER放到包描述符的NDIS_BUFFER链表的尾节点</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 128, 0); ">
</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">    NdisChainBufferAtBack(Packet, Buffer);

    NdisTransferData(</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">Status, Context</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">-&gt;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">BindingHandle, MacReceiveContext, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">0</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">, PacketSize, Packet, </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">&amp;</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">BytesTransferred);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">if</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> (Status </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); ">!=</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> NDIS_STATUS_PENDING) 
        ProtocolTransferDataComplete(ProtocolBindingContext, Packet, Status, BytesTransferred);
    </span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 255); ">return</span></span><span style="font-family: monospace; font-size: 13px; white-space: pre; "><span style="color: rgb(0, 0, 0); "> Status;
}</span></span></div><img src ="http://www.cppblog.com/ngaut/aggbug/126145.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2010-09-08 10:43 <a href="http://www.cppblog.com/ngaut/archive/2010/09/08/126145.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Google C++ Testing Framework Primer</title><link>http://www.cppblog.com/ngaut/archive/2008/08/31/60514.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sun, 31 Aug 2008 12:19:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2008/08/31/60514.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/60514.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2008/08/31/60514.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/60514.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/60514.html</trackback:ping><description><![CDATA[<div id="blog_text" class="cnt">
<p><strong>Google C++ Testing Framework Primer</strong></p>
<p>翻译：<a  href="http://rayleex.spaces.live.com/blog/cns%21C32DFA3924AF2128%21218.entry"><font color="#669966">Ray Li </font></a>(<a  href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#97;&#121;&#46;&#108;&#101;&#101;&#120;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;"><font color="#669966">ray.leex@gmail.com</font></a>) <br>
修改日期：2008年7月6日<br>
原文参见：<a  href="http://code.google.com/p/googletest/wiki/GoogleTestPrimer"><font color="#669966">http://code.google.com/p/googletest/wiki/GoogleTestPrimer</font></a></p>
<p><strong>Introduction</strong><strong>：为什么需要</strong><strong>Google C++ </strong><strong>测试框架？</strong></p>
<p>Google C++ 测试框架帮助你更好地编写C++测试。</p>
<p>无论你是在Linux，Windows，还是Mac环境下工作，只要你编写C++代码，Google 测试框架都可以帮上忙。</p>
<p>那么，哪些因素才能构成一个好的测试？以及，Google C++ 测试框架怎样满足这些因素？我们相信：</p>
<ol>
    <li>测试应该是<em>独立</em>、<em>可重复</em>的。因为其他测试成功或失败而导致我们要对自己的测试进行debug是非常痛苦的。Google C++ 测试框架通过将每个测试在不同的对象中运行，使得测试分离开来。当一个测试失败时，Google C++ 测试框架允许你独立运行它以进行快速除错。</li>
    <li>测试应该能够被很好地<em>组织</em>，并反映被测代码的结构。Google C++ 测试框架将测试组织成测试案例，案例中的测试可以共享数据和程序分支。这样一种通用模式能够很容易辨识，使得我们的测试容易维护。当开发人员在项目之间转换，开始在一个新的代码基上开始工作时，这种一致性格外有用。</li>
    <li>测试应该是<em>可移植</em>、<em>可重用</em>的。开源社区有很多平台独立的代码，它们的测试也应该是平台独立的。除开一些特殊情况，Google C++ 测试框架运行在不同的操作系统上、与不同的编译器（gcc、icc、MSVC）搭配，Google C++ 测试框架的测试很容易与不同的配置一起工作。</li>
    <li>当测试失败时，应该提供尽可能多的、关于问题的<em>信息</em>。Google C++ 测试框架在第一个测试失败时不会停下来。相反，它只是将当前测试停止，然后继续接下来的测试。你也可以设置对一些非致命的错误进行报告，并接着进行当前的测试。这样，你就可以在一次&#8220;运行-编辑-编译&#8221;循环中检查到并修复多个bug。</li>
    <li>测试框架应该能将测试编写人员从一些环境维护的工作中解放出来，使他们能够集中精力于测试的<em>内容</em>。Google C++ 测试框架自动记录下所有定义好的测试，不需要用户通过列举来指明哪些测试需要运行。</li>
    <li>测试应该<em>快速</em>。使用Google C++ 测试框架，你可以重用多个测试的共享资源，一次性完成设置/解除设置，而不用使一个测试去依赖另一测试。</li>
</ol>
<p>因为Google C++ 测试框架基于著名的xUnit架构，如果你之前使用过JUnit或PyUnit的话，你将会感觉非常熟悉。如果你没有接触过这些测试框架，它也只会占用你大约10分钟的时间来学习基本概念和上手。所以，让我们开始吧！</p>
<p>Note：本文偶尔会用&#8220;Google Test&#8221;来代指&#8220;Google C++ 测试框架&#8221;。</p>
<p><strong>基本概念</strong></p>
<p>使用Google Test时，你是从编写<em>断言</em>开始的，而断言是一些检查条件是否为真的语句。一个断言的结果可能是成功、非致命失败，或者致命失败。如果一个致命失败出现，他会结束当前的函数；否则，程序继续正常运行。</p>
<p><em>测试</em>使用断言来验证被测代码的行为。如果一个测试崩溃或是出现一个失败的断言，那么，该测试<em>失败</em>；否则该测试<em>成功</em>。</p>
<p>一个测试案例（test case）包含了一个或多个测试。你应该将自己的测试分别归类到测试案例中，以反映被测代码的结构。当测试案例中的多个测试需要共享通用对象和子程序时，你可以把他们放到一个测试固件（<em>test fixture</em>）类中。</p>
<p>一个<em>测试程序</em>可以包含多个测试案例。</p>
<p>从编写单个的断言开始，到创建测试和测试案例，我们将会介绍怎样编写一个测试程序。</p>
<p><strong>断言</strong></p>
<p>Google Test中的断言是一些与函数调用相似的宏。要测试一个类或函数，我们需要对其行为做出断言。当一个断言失败时，Google
Test会在屏幕上输出该代码所在的源文件及其所在的位置行号，以及错误信息。也可以在编写断言时，提供一个自定义的错误信息，这个信息在失败时会被附加
在Google Test的错误信息之后。</p>
<p>断言常常成对出现，它们都测试同一个类或者函数，但对当前功能有着不同的效果。ASSERT_*版本的断言失败时会产生致命失败，并<strong>结束当前函数</strong>。EXPECT_*版本的断言产生非致命失败，而不会中止当前函数。通常更推荐使用EXPECT_*断言，因为它们运行一个测试中可以有不止一个的错误被报告出来。但如果在编写断言如果失败，就没有必要继续往下执行的测试时，你应该使用ASSERT_*断言。</p>
<p>因为失败的ASSERT_*断言会立刻从当前的函数返回，可能会跳过其后的一些的清洁代码，这样也许会导致空间泄漏。根据泄漏本身的特质，这种情况
也许值得修复，也可能不值得我们关心——所以，如果你得到断言错误的同时，还得到了一个堆检查的错误，记住上面我们所说的这一点。</p>
<p>要提供一个自定义的错误消息，只需要使用&lt;&lt;操作符，或一个&lt;&lt;操作符的序列，将其输入到框架定义的宏中。下面是一个例子：</p>
<p>Cpp代码</p>
<ol>
    <li>ASSERT_EQ(x.size(), y.size()) &lt;&lt; "Vectors x and y are of unequal length"; &nbsp;&nbsp;</li>
    <li>for (int i = 0; i &lt; x.size(); ++i) { &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(x[i], y[i]) &lt;&lt; "Vectors x and y differ at index " &lt;&lt; i; &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>ASSERT_EQ(x.size(), y.size()) &lt;&lt; "Vectors x and y are of unequal length";<br>for (int i = 0; i &lt; x.size(); ++i) {<br>  EXPECT_EQ(x[i], y[i]) &lt;&lt; "Vectors x and y differ at index " &lt;&lt; i;<br>}</pre>
<p>任何能够被输出到ostream中的信息都可以被输出到一个断言宏中——特别是C字符串和string对象。如果一个宽字符串
（wchar_t*，windows上UNICODE模式TCHAR*或std::wstring）被输出到一个断言中，在打印时它会被转换成UTF-8
编码。</p>
<p><strong>基本断言</strong></p>
<p>下面这些断言实现了基本的true/false条件测试。</p>
<p><strong>致命断言</strong><br>
<strong>非致命断言</strong><br>
<strong>验证条件</strong></p>
<p>ASSERT_TRUE(<em>condition</em>);<br>
EXPECT_TRUE(<em>condition</em>); <br>
<em>condition</em>为真</p>
<p>ASSERT_FALSE(<em>condition</em>); <br>
EXPECT_FALSE(<em>condition</em>); <br>
<em>condition</em> 为假</p>
<p>记住，当它们失败时，ASSERT_*产生一个致命失败并从当前函数返回，而EXCEPT_*产生一个非致命失败，允许函数继续运行。在两种情况下，一个断言失败都意味着它所包含的测试失败。</p>
<p>有效平台：Linux、Windows、Mac。</p>
<p><strong>二进制比较</strong></p>
<p>本节描述了比较两个值的一些断言。</p>
<p><strong>致命断言</strong><br>
<strong>非致命断言</strong><br>
<strong>验证条件</strong></p>
<p>ASSERT_EQ(<em>expected</em>, <em>actual</em>);<br>
EXPECT_EQ(<em>expected</em>, <em>actual</em>);<br>
<em>expected</em> == <em>actual</em></p>
<p>ASSERT_NE(<em>val1</em>, <em>val2</em>);<br>
EXPECT_NE(<em>val1</em>, <em>val2</em>);<br>
<em>val1</em> != <em>val2</em></p>
<p>ASSERT_LT(<em>val1</em>, <em>val2</em>);<br>
EXPECT_LT(<em>val1</em>, <em>val2</em>);<br>
<em>val1</em> &lt; <em>val2</em></p>
<p>ASSERT_LE(<em>val1</em>, <em>val2</em>);<br>
EXPECT_LE(<em>val1</em>, <em>val2</em>);<br>
<em>val1</em> &lt;= <em>val2</em></p>
<p>ASSERT_GT(<em>val1</em>, <em>val2</em>);<br>
EXPECT_GT(<em>val1</em>, <em>val2</em>);<br>
<em>val1</em> &gt; <em>val2</em></p>
<p>ASSERT_GE(<em>val1</em>, <em>val2</em>);<br>
EXPECT_GE(<em>val1</em>, <em>val2</em>);<br>
<em>val1</em> &gt;= <em>val2</em></p>
<p>在出现失败事件时，Google Test会将两个值（<em>Val1</em>和<em>Val2</em>）都打印出来。在ASSERT_EQ*和EXCEPT_EQ*断言（以及我们随后介绍类似的断言）中，你应该把你希望测试的表达式放在<em>actual</em>（实际值）的位置上，将其期望值放在<em>expected</em>（期望值）的位置上，因为Google Test的测试消息为这种惯例做了一些优化。</p>
<p>参数值必须是可通过断言的比较操作符进行比较的，否则你会得到一个编译错误。参数值还必须支持&lt;&lt;操作符来将值输入到ostream中。所有的C++内置类型都支持这一点。</p>
<p>这些断言可以用于用户自定义的型别，但你必须重载相应的比较操作符（如==、&lt;等）。如果定义有相应的操作符，推荐使用ASSERT_*()宏，因为它们不仅会输出比较的结果，还会输出两个比较对象。</p>
<p>参数表达式总是只被解析一次。因此，参数表达式有一定的副作用（side
effect，这里应该是指编译器不同，操作符解析顺序的不确定性）也是可以接受的。但是，同其他普通C/C++函数一样，参数表达式的解析顺序是不确定
的（如，一种编译器可以自由选择一种顺序来进行解析），而你的代码不应该依赖于某种特定的参数解析顺序。</p>
<p>ASSERT_EQ()对指针进行的是指针比较。即，如果被用在两个C字符串上，它会比较它们是否指向同样的内存地址，而不是它们所指向的字符串是
否有相同值。所以，如果你想对两个C字符串（例如，const
char*）进行值比较，请使用ASSERT_STREQ()宏，该宏会在后面介绍到。特别需要一提的是，要验证一个C字符串是否为空（NULL），使用
ASSERT_STREQ(NULL, c_string)。但是要比较两个string对象时，你应该使用ASSERT_EQ。</p>
<p>本节中介绍的宏都可以处理窄字符串对象和宽字符串对象（string和wstring）。</p>
<p>有效平台：Linux、Windows、Mac。</p>
<p><strong>字符串比较</strong></p>
<p>该组断言用于比较两个C字符串。如果你想要比较两个string对象，相应地使用EXPECT_EQ、EXPECT_NE等断言。</p>
<p><strong>致命断言</strong><br>
<strong>非致命断言</strong><br>
<strong>验证条件</strong></p>
<p>ASSERT_STREQ(<em>expected_str</em>, <em>actual_str</em>);<br>
EXPECT_STREQ(<em>expected_str</em>, <em>actual_str</em>);<br>
两个C字符串有相同的内容</p>
<p>ASSERT_STRNE(<em>str1</em>, <em>str2</em>);<br>
EXPECT_STRNE(<em>str1</em>, <em>str2</em>);<br>
两个C字符串有不同的内容</p>
<p>ASSERT_STRCASEEQ(<em>expected_str</em>, <em>actual_str</em>);<br>
EXPECT_STRCASEEQ(<em>expected_str</em>, <em>actual_str</em>);<br>
两个C字符串有相同的内容，忽略大小写</p>
<p>ASSERT_STRCASENE(<em>str1</em>, <em>str2</em>);<br>
EXPECT_STRCASENE(<em>str1</em>, <em>str2</em>);<br>
两个C字符串有不同的内容，忽略大小写</p>
<p>注意断言名称中出现的&#8220;CASE&#8221;意味着大小写被忽略了。</p>
<p>*STREQ*和*STRNE*也接受宽字符串（wchar_t*）。如果两个宽字符串比较失败，它们的值会做为UTF-8窄字符串被输出。</p>
<p>一个NULL空指针和一个空字符串会被认为是<em>不一样</em>的。</p>
<p>有效平台：Linux、Windows、Mac。</p>
<p>参见：更多的字符串比较的技巧（如子字符串、前缀和正则表达式匹配），请参见[Advanced Guide Advanced Google Test Guide]。</p>
<p><strong>简单的测试</strong></p>
<p>要创建一个测试：</p>
<ol>
    <li>使用TEST（）宏来定义和命名一个测试函数，它们是一些没有返回值的普通C++函数。</li>
    <li>在这个函数中，与你想要包含的其它任何有效C++代码一起，使用Google Test提供的各种断言来进行检查。</li>
    <li>测试的结果由其中的断言决定；如果测试中的任意断言失败（无论是致命还是非致命），或者测试崩溃，那么整个测试就失败了。否则，测试通过。 </li>
</ol>
<p>Cpp代码</p>
<ol>
    <li>TEST(test_case_name, test_name) { &nbsp;&nbsp;</li>
    <li>... test body ... &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>TEST(test_case_name, test_name) {<br>... test body ...<br>}</pre>
<p>TEST（）的参数是从概括到特殊的。<em>第一个</em>参数是测试案例的名称，<em>第二个</em>参数是测试案例中的测试的名称。记住，一个测试案例可以包含任意数量的独立测试。一个测试的<em>全称</em>包括了包含它的测试案例名称，及其独立的名称。不同测试案例中的独立测试可以有相同的名称。</p>
<p>举例来说，让我们看一个简单的整数函数：</p>
<p>Cpp代码</p>
<ol>
    <li>int Factorial(int n); // 返回n的阶乘</li>
</ol>
<pre>int Factorial(int n); // 返回n的阶乘</pre>
<p>这个函数的测试案例应该看起来像是：</p>
<p>Cpp代码</p>
<ol>
    <li>// 测试0的阶乘</li>
    <li>TEST(FactorialTest, HandlesZeroInput) { &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(1, Factorial(0)); &nbsp;&nbsp;</li>
    <li>} &nbsp;&nbsp;</li>
    <li>// 测试正数的阶乘</li>
    <li>TEST(FactorialTest, HandlesPositiveInput) { &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(1, Factorial(1)); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(2, Factorial(2)); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(6, Factorial(3)); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(40320, Factorial(8)); &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>// 测试0的阶乘<br>TEST(FactorialTest, HandlesZeroInput) {<br>  EXPECT_EQ(1, Factorial(0));<br>}<br>// 测试正数的阶乘<br>TEST(FactorialTest, HandlesPositiveInput) {<br>  EXPECT_EQ(1, Factorial(1));<br>  EXPECT_EQ(2, Factorial(2));<br>  EXPECT_EQ(6, Factorial(3));<br>  EXPECT_EQ(40320, Factorial(8));<br>}</pre>
<p>Google
Test根据测试案例来分组收集测试结果，因此，逻辑相关的测试应该在同一测试案例中；换句话说，它们的TEST（）的第一个参数应该是一样的。在上面的
例子中，我们有两个测试，HandlesZeroInput和HandlesPostiveInput，它们都属于同一个测试案例
FactorialTest。</p>
<p>有效平台：Linux、Windows、Mac。</p>
<p><strong>测试固件（</strong><strong>Test Fixtures</strong><strong>，又做测试夹具、测试套件）：在多个测试中使用同样的数据配置</strong></p>
<p>当你发现自己编写了两个或多个测试来操作同样的数据，你可以采用一个<em>测试固件</em>。它让你可以在多个不同的测试中重用同样的对象配置。</p>
<p>要创建测试固件，只需：</p>
<ol>
    <li>创建一个类继承自testing::Test。将其中的成员声明为protected:或是public:，因为我们想要从子类中存取固件成员。</li>
    <li>在该类中声明你计划使用的任何对象。</li>
    <li>如果需要，编写一个默认构造函数或者SetUp()函数来为每个测试准备对象。常见错误包括将SetUp()拼写为Setup()（小写了u）——不要让它发生在你身上。</li>
    <li>如果需要，编写一个析构函数或者TearDown()函数来释放你在SetUp()函数中申请的资源。要知道什么时候应该使用构造函数/析构函数，什么时候又应该使用SetUp()/TearDown()函数，阅读我们的FAQ。</li>
    <li>如果需要，定义你的测试所需要共享的子程序。</li>
</ol>
<p>当我们要使用固件时，使用TEST_F()替换掉TEST()，它允许我们存取测试固件中的对象和子程序：</p>
<p>Cpp代码</p>
<ol>
    <li>TEST_F(test_case_name, test_name) { &nbsp;&nbsp;</li>
    <li>... test body ... &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>TEST_F(test_case_name, test_name) {<br>... test body ...<br>}</pre>
<p>与TEST()一样，第一个参数是测试案例的名称，但对TEST_F()来说，这个名称必须与测试固件类的名称一些。你可能已经猜到了：_F正是指固件。</p>
<p>不幸地是，C++宏系统并不允许我们创建一个单独的宏来处理两种类型的测试。使用错误的宏会导致编译期的错误。</p>
<p>而且，你必须在TEST_F()中使用它之前，定义好这个测试固件类。否则，你会得到编译器的报错：&#8220;virtual outside class declaration&#8221;。</p>
<p>对于TEST_F()中定义的每个测试，Google Test将会：</p>
<ol>
    <li>在运行时创建一个<em>全新</em>的测试固件</li>
    <li>马上通过SetUp()初始化它，</li>
    <li>运行测试</li>
    <li>调用TearDown()来进行清理工作</li>
    <li>删除测试固件。注意，同一测试案例中，不同的测试拥有不同的测试固件。Google Test在创建下一个测试固件前总是会对现有固件进行删除。Google Test不会对多个测试重用一个测试固件。测试对测试固件的改动并不会影响到其他测试。</li>
</ol>
<p>例如，让我们为一个名为Queue的FIFO队列类编写测试，该类的接口如下：</p>
<p>Cpp代码</p>
<ol>
    <li>template &lt;typename E&gt; // E为元素类型</li>
    <li>class Queue { &nbsp;&nbsp;</li>
    <li>public: &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; Queue(); &nbsp;&nbsp;</li>
    <li>void Enqueue(const E&amp; element); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; E* Dequeue(); // 返回 NULL 如果队列为空.</li>
    <li>size_t size() const; &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; ... &nbsp;&nbsp;</li>
    <li>};&nbsp;&nbsp;</li>
</ol>
<pre>template &lt;typename E&gt; // E为元素类型<br>class Queue {<br>public:<br>  Queue();<br>  void Enqueue(const E&amp; element);<br>  E* Dequeue(); // 返回 NULL 如果队列为空.<br>  size_t size() const;<br>  ...<br>};</pre>
<p>首先，定义一个固件类。习惯上，你应该把它的名字定义为FooTest，这里的Foo是被测试的类。</p>
<p>Cpp代码</p>
<ol>
    <li>class QueueTest : public testing::Test { &nbsp;&nbsp;</li>
    <li>protected: &nbsp;&nbsp;</li>
    <li>virtual void SetUp() { &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp;&nbsp;&nbsp; q1_.Enqueue(1); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp;&nbsp;&nbsp; q2_.Enqueue(2); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp;&nbsp;&nbsp; q2_.Enqueue(3); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; } &nbsp;&nbsp;</li>
    <li>// virtual void TearDown() {}</li>
    <li>&nbsp;&nbsp; Queue&lt;int&gt; q0_; &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; Queue&lt;int&gt; q1_; &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; Queue&lt;int&gt; q2_; &nbsp;&nbsp;</li>
    <li>};&nbsp;&nbsp;</li>
</ol>
<pre>class QueueTest : public testing::Test {<br>protected:<br>  virtual void SetUp() {<br>    q1_.Enqueue(1);<br>    q2_.Enqueue(2);<br>    q2_.Enqueue(3);<br>  }<br>  // virtual void TearDown() {}<br>  Queue&lt;int&gt; q0_;<br>  Queue&lt;int&gt; q1_;<br>  Queue&lt;int&gt; q2_;<br>};</pre>
<p>在这个案例中，我们不需要TearDown()，因为每个测试后除了析构函数外不需要进行其它的清理工作了。</p>
<p>接下来我们使用TEST_F()和这个固件来编写测试。</p>
<p>Cpp代码</p>
<ol>
    <li>TEST_F(QueueTest, IsEmptyInitially) { &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(0, q0_.size()); &nbsp;&nbsp;</li>
    <li>} &nbsp;&nbsp;</li>
    <li>TEST_F(QueueTest, DequeueWorks) { &nbsp;&nbsp;</li>
    <li>int* n = q0_.Dequeue(); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(NULL, n); &nbsp;&nbsp;</li>
    <li> <br></li>
    <li>&nbsp;&nbsp; n = q1_.Dequeue(); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; ASSERT_TRUE(n != NULL); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(1, *n); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(0, q1_.size()); &nbsp;&nbsp;</li>
    <li>delete n; &nbsp;&nbsp;</li>
    <li> <br></li>
    <li>&nbsp;&nbsp; n = q2_.Dequeue(); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; ASSERT_TRUE(n != NULL); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(2, *n); &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(1, q2_.size()); &nbsp;&nbsp;</li>
    <li>delete n; &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>TEST_F(QueueTest, IsEmptyInitially) {<br>  EXPECT_EQ(0, q0_.size());<br>}<br>TEST_F(QueueTest, DequeueWorks) {<br>  int* n = q0_.Dequeue();<br>  EXPECT_EQ(NULL, n);<br><br>  n = q1_.Dequeue();<br>  ASSERT_TRUE(n != NULL);<br>  EXPECT_EQ(1, *n);<br>  EXPECT_EQ(0, q1_.size());<br>  delete n;<br><br>  n = q2_.Dequeue();<br>  ASSERT_TRUE(n != NULL);<br>  EXPECT_EQ(2, *n);<br>  EXPECT_EQ(1, q2_.size());<br>  delete n;<br>}</pre>
<p>上面这段代码既使用了ASSERT_*断言，又使用了EXPECT_*断言。经验上讲，如果你想要断言失败后，测试能够继续进行以显示更多的错误
时，你应该使用EXPECT_*断言；使用ASSERT_*如果该断言失败后继续往下执行毫无意义。例如，Dequeue测试中的第二个断言是
ASSERT_TURE(n!= NULL)，因为我们随后会n指针解引用，如果n指针为空的话，会导致一个段错误。</p>
<p>当这些测试开始时，会发生如下情况：</p>
<ol>
    <li>Google Test创建一个QueueTest对象（我们把它叫做t1）。</li>
    <li>t1.SetUp()初始化t1。</li>
    <li>第一个测试（IsEmptyInitiallly）在t1上运行。</li>
    <li>测试完成后，t1.TearDown()进行一些清理工作。</li>
    <li>t1被析构。</li>
    <li>以上步骤在另一个QueueTest对象上重复进行，这回会运行DequeueWorks测试。</li>
</ol>
<p>有效平台：Linux、Windows、Mac。</p>
<p>注意：当一个测试对象被构造时，Google Test会自动地保存所有的Google Test变量标识，对象析构后进行恢复。</p>
<p><strong>调用测试</strong></p>
<p>TEST()和TEST_F()向Google Test隐式注册它们的测试。因此，与很多其他的C++测试框架不同，你不需要为了运行你定义的测试而将它们全部再列出来一次。</p>
<p>在定义好测试后，你可以通过RUN_ALL_TESTS()来运行它们，如果所有测试成功，该函数返回0，否则会返回1.注意RUN_ALL_TESTS()会运行你链接到的所有测试——它们可以来自不同的测试案例，甚至是来自不同的文件。</p>
<p>当被调用时，RUN_ALL_TESTS()宏会：</p>
<ol>
    <li>保存所有的Google Test标志。</li>
    <li>为一个侧测试创建测试固件对象。</li>
    <li>调用SetUp()初始化它。</li>
    <li>在固件对象上运行测试。</li>
    <li>调用TearDown()清理固件。</li>
    <li>删除固件。</li>
    <li>恢复所有Google Test标志的状态。</li>
    <li>重复上诉步骤，直到所有测试完成。</li>
</ol>
<p>此外，如果第二步时，测试固件的构造函数产生一个致命错误，继续执行3至5部显然没有必要，所以它们会被跳过。与之相似，如果第3部产生致命错误，第4部也会被跳过。</p>
<p>重要：你不能忽略掉RUN_ALL_TESTS()的返回值，否则gcc会报一个编译错误。这样设计的理由是自动化测试服务会根据测试退出返回码来
决定一个测试是否通过，而不是根据其stdout/stderr输出；因此你的main()函数必须返回RUN_ALL_TESTS()的值。</p>
<p>而且，你应该只调用RUN_ALL_TESTS()一次。多次调用该函数会与Google Test的一些高阶特性（如线程安全死亡测试thread-safe death tests）冲突，因而是不被支持的。</p>
<p>有效平台：Linux、Windows、Mac。</p>
<p><strong>编写</strong><strong>main()</strong><strong>函数</strong></p>
<p>你可以从下面这个样板开始:</p>
<p>Cpp代码</p>
<ol>
    <li>#include "this/package/foo.h"</li>
    <li>#include &lt;gtest/gtest.h&gt;</li>
    <li>namespace { &nbsp;&nbsp;</li>
    <li>// 测试Foo类的测试固件</li>
    <li>class FooTest : public testing::Test { &nbsp;&nbsp;</li>
    <li>protected: &nbsp;&nbsp;</li>
    <li>// You can remove any or all of the following functions if its body</li>
    <li>// is empty.</li>
    <li>&nbsp;&nbsp; FooTest() { &nbsp;&nbsp;</li>
    <li>// You can do set-up work for each test here.</li>
    <li>&nbsp;&nbsp; } &nbsp;&nbsp;</li>
    <li>virtual ~FooTest() { &nbsp;&nbsp;</li>
    <li>// You can do clean-up work that doesn't throw exceptions here.</li>
    <li>&nbsp;&nbsp; } &nbsp;&nbsp;</li>
    <li>// If the constructor and destructor are not enough for setting up</li>
    <li>// and cleaning up each test, you can define the following methods:</li>
    <li>virtual void SetUp() { &nbsp;&nbsp;</li>
    <li>// Code here will be called immediately after the constructor (right</li>
    <li>// before each test).</li>
    <li>&nbsp;&nbsp; } &nbsp;&nbsp;</li>
    <li>virtual void TearDown() { &nbsp;&nbsp;</li>
    <li>// Code here will be called immediately after each test (right</li>
    <li>// before the destructor).</li>
    <li>&nbsp;&nbsp; } &nbsp;&nbsp;</li>
    <li>// Objects declared here can be used by all tests in the test case for Foo.</li>
    <li>}; &nbsp;&nbsp;</li>
    <li> <br></li>
    <li>// Tests that the Foo::Bar() method does Abc.</li>
    <li>TEST_F(FooTest, MethodBarDoesAbc) { &nbsp;&nbsp;</li>
    <li>const string input_filepath = "this/package/testdata/myinputfile.dat"; &nbsp;&nbsp;</li>
    <li>const string output_filepath = "this/package/testdata/myoutputfile.dat"; &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; Foo f; &nbsp;&nbsp;</li>
    <li>&nbsp;&nbsp; EXPECT_EQ(0, f.Bar(input_filepath, output_filepath)); &nbsp;&nbsp;</li>
    <li>} &nbsp;&nbsp;</li>
    <li> <br></li>
    <li>// Tests that Foo does Xyz.</li>
    <li>TEST_F(FooTest, DoesXyz) { &nbsp;&nbsp;</li>
    <li>// Exercises the Xyz feature of Foo.</li>
    <li>} &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp; // namespace</li>
    <li> <br></li>
    <li>int main(int argc, char **argv) { &nbsp;&nbsp;</li>
    <li>testing::InitGoogleTest(&amp;argc, argv); &nbsp;&nbsp;</li>
    <li>return RUN_ALL_TESTS(); &nbsp;&nbsp;</li>
    <li>}&nbsp;&nbsp;</li>
</ol>
<pre>#include "this/package/foo.h"<br>#include &lt;gtest/gtest.h&gt;<br>namespace {<br>// 测试Foo类的测试固件<br>class FooTest : public testing::Test {<br>protected:<br>  // You can remove any or all of the following functions if its body<br>  // is empty.<br>  FooTest() {<br>    // You can do set-up work for each test here.<br>  }<br>  virtual ~FooTest() {<br>    // You can do clean-up work that doesn't throw exceptions here.<br>  }<br>  // If the constructor and destructor are not enough for setting up<br>  // and cleaning up each test, you can define the following methods:<br>  virtual void SetUp() {<br>    // Code here will be called immediately after the constructor (right<br>    // before each test).<br>  }<br>  virtual void TearDown() {<br>    // Code here will be called immediately after each test (right<br>    // before the destructor).<br>  }<br>  // Objects declared here can be used by all tests in the test case for Foo.<br>};<br><br>// Tests that the Foo::Bar() method does Abc.<br>TEST_F(FooTest, MethodBarDoesAbc) {<br>  const string input_filepath = "this/package/testdata/myinputfile.dat";<br>  const string output_filepath = "this/package/testdata/myoutputfile.dat";<br>  Foo f;<br>  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));<br>}<br><br>// Tests that Foo does Xyz.<br>TEST_F(FooTest, DoesXyz) {<br>  // Exercises the Xyz feature of Foo.<br>}<br>}  // namespace<br><br>int main(int argc, char **argv) {<br>  testing::InitGoogleTest(&amp;argc, argv);<br>  return RUN_ALL_TESTS();<br>}</pre>
<p>testing::InitGoogleTest()函数负责解析命令行传入的Google
Test标志，并删除所有它可以处理的标志。这使得用户可以通过各种不同的标志控制一个测试程序的行为。关于这一点我们会在GTestAdvanced中
讲到。你必须在调用RUN_ALL_TESTS()之前调用该函数，否则就无法正确地初始化标示。</p>
<p>在Windows上InitGoogleTest()可以支持宽字符串，所以它也可以被用在以UNICODE模式编译的程序中。</p>
<p><strong>进阶阅读</strong></p>
<p>恭喜你！你已经学到了一些Google Test基础。你可以从编写和运行几个Google Test测试开始，再阅读一下<a  href="http://code.google.com/p/googletest/wiki/GoogleTestSamples"><font color="#669966">GoogleTestSamples</font></a>，或是继续研究<a  href="http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide"><font color="#669966">GoogleTestAdvancedGuide</font></a>，其中描述了很多更有用的Google Test特性。</p>
<p><strong>已知局限</strong></p>
<p>Google Test被设计为线程安全的。但是，我们还没有时间在各种平台上实现同步原语（synchronization
primitives）。因此，目前从两个线程同时使用Google
Test断言是不安全的。由于通常断言是在主线程中完成的，因此在大多数测试中这都不算问题。如果你愿意帮忙，你可以试着在gtest-port.h中实
现必要的同步原语。</p>
</div><img src ="http://www.cppblog.com/ngaut/aggbug/60514.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2008-08-31 20:19 <a href="http://www.cppblog.com/ngaut/archive/2008/08/31/60514.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Visual C++开发工具与调试技巧整理</title><link>http://www.cppblog.com/ngaut/archive/2008/07/26/57181.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 25 Jul 2008 17:19:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2008/07/26/57181.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/57181.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2008/07/26/57181.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/57181.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/57181.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2008/07/26/57181.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/57181.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2008-07-26 01:19 <a href="http://www.cppblog.com/ngaut/archive/2008/07/26/57181.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Add color to your std::cout</title><link>http://www.cppblog.com/ngaut/archive/2008/07/14/56138.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Mon, 14 Jul 2008 15:03:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2008/07/14/56138.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/56138.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2008/07/14/56138.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/56138.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/56138.html</trackback:ping><description><![CDATA[<span id="intelliTXT">
<h2>Introduction</h2>
<p>This article illustrates a snippet that permits to add color to console messages.</p>
<h2>Background</h2>
<p>Well, does it really need any comments? </p>
<h2>Using the code</h2>
<p>This sample shows how to use the library:</p>
<pre><span class="code-preprocessor">#include</span><span class="code-preprocessor"> <span class="code-string">"</span><span class="code-string">ConsoleColor.h"</span><br></span><br><br>std::cout <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> green <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> <span class="code-string">"</span><span class="code-string">This text is written in green"</span> <br>          <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> white <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> std::endl;<br>std::cout <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> color(FOREGROUND_RED|FOREGROUND_GREEN) <br>          <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> <span class="code-string">"</span><span class="code-string">This text has a really exiting color !"</span> <br>          <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> white <span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span> std::endl;<br></pre>
<p>Now here is the "library":</p>
<div class="SmallText" id="premain1" style="width: 100%; cursor: pointer;"><img  src="http://www.codeproject.com/images/minus.gif" preid="1" id="preimg1" width="9" height="9"><span preid="1" style="margin-bottom: 0pt;" id="precollapse1"> Collapse</span></div>
<pre style="margin-top: 0pt;" id="pre1"><span class="code-comment">//</span><span class="code-comment"> ConsoleColor.h<br></span><br><br><span class="code-preprocessor">#pragma</span> once<br><span class="code-preprocessor">#include</span><span class="code-preprocessor"> <span class="code-keyword">&lt;</span><span class="code-leadattribute">iostream</span><span class="code-keyword">&gt;</span><br></span><br><span class="code-preprocessor">#include</span><span class="code-preprocessor"> <span class="code-keyword">&lt;</span><span class="code-leadattribute">windows.h</span><span class="code-keyword">&gt;</span><br></span><br><br><span class="code-keyword">inline</span> std::ostream&amp; blue(std::ostream &amp;s)<br>{<br>    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE<br>              |FOREGROUND_GREEN|FOREGROUND_INTENSITY);<br>    <span class="code-keyword">return</span> s;<br>}<br><br><span class="code-keyword">inline</span> std::ostream&amp; red(std::ostream &amp;s)<br>{<br>    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout, <br>                FOREGROUND_RED|FOREGROUND_INTENSITY);<br>    <span class="code-keyword">return</span> s;<br>}<br><br><span class="code-keyword">inline</span> std::ostream&amp; green(std::ostream &amp;s)<br>{<br>    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout, <br>              FOREGROUND_GREEN|FOREGROUND_INTENSITY);<br>    <span class="code-keyword">return</span> s;<br>}<br><br><span class="code-keyword">inline</span> std::ostream&amp; yellow(std::ostream &amp;s)<br>{<br>    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout, <br>         FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);<br>    <span class="code-keyword">return</span> s;<br>}<br><br><span class="code-keyword">inline</span> std::ostream&amp; white(std::ostream &amp;s)<br>{<br>    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout, <br>       FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);<br>    <span class="code-keyword">return</span> s;<br>}<br><br><span class="code-keyword">struct</span> color {<br>    color(WORD attribute):m_color(attribute){};<br>    WORD m_color;<br>};<br><br><span class="code-keyword">template</span> <span class="code-keyword">&lt;</span><span class="code-keyword">class</span> _Elem, <span class="code-keyword">class</span> _Traits<span class="code-keyword">&gt;</span><br>std::basic_ostream<span class="code-keyword">&lt;</span>_Elem,_Traits<span class="code-keyword">&gt;</span>&amp; <br>      <span class="code-keyword">operator</span><span class="code-keyword">&lt;</span><span class="code-keyword">&lt;</span>(std::basic_ostream<span class="code-keyword">&lt;</span>_Elem,_Traits<span class="code-keyword">&gt;</span>&amp; i, color&amp; c)<br>{<br>    HANDLE hStdout=GetStdHandle(STD_OUTPUT_HANDLE); <br>    SetConsoleTextAttribute(hStdout,c.m_color);<br>    <span class="code-keyword">return</span> i;<br>}<br><br><span class="code-comment">//</span><span class="code-comment"> Copyleft Vincent Godin</span></pre>
</span><img src ="http://www.cppblog.com/ngaut/aggbug/56138.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2008-07-14 23:03 <a href="http://www.cppblog.com/ngaut/archive/2008/07/14/56138.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Huffman编码STL版--来自fxsjy的专栏 </title><link>http://www.cppblog.com/ngaut/archive/2007/12/30/40001.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sun, 30 Dec 2007 05:55:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/12/30/40001.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/40001.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/12/30/40001.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/40001.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/40001.html</trackback:ping><description><![CDATA[<font color=#002c99>Huffman编码STL版</font>&nbsp;&nbsp;
<script src="http://blog.csdn.net/count.aspx?ID=1395927&amp;Type=Rank"></script>
<span title=文章指数:80><img src="http://blog.csdn.net/images/star.gif" border=0><img src="http://blog.csdn.net/images/star.gif" border=0><img src="http://blog.csdn.net/images/star.gif" border=0><img src="http://blog.csdn.net/images/star.gif" border=0></span>&nbsp;&nbsp;<img title="CSDN Blog推出文章指数概念，文章指数是对Blog文章综合评分后推算出的，综合评分项分别是该文章的点击量，回复次数，被网摘收录数量，文章长度和文章类型；满分100，每月更新一次。" alt="CSDN Blog推出文章指数概念，文章指数是对Blog文章综合评分后推算出的，综合评分项分别是该文章的点击量，回复次数，被网摘收录数量，文章长度和文章类型；满分100，每月更新一次。" src="http://blog.csdn.net/images/ask.gif" border=0>
<div class=postText>
<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<div><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">algorithm</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">functional</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">&nbsp;std;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;TreeNode<br><img id=_119_243_Open_Image onclick="this.style.display='none'; document.getElementById('_119_243_Open_Text').style.display='none'; document.getElementById('_119_243_Closed_Image').style.display='inline'; document.getElementById('_119_243_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_119_243_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_119_243_Closed_Text').style.display='none'; document.getElementById('_119_243_Open_Image').style.display='inline'; document.getElementById('_119_243_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_119_243_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_119_243_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">double</span><span style="COLOR: #000000">&nbsp;Weight;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">权值</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;flag;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">代表符号如a,b,c，如果为非叶子节点flag=='-'</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;TreeNode</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;left;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">左子树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">&nbsp;TreeNode</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">&nbsp;right;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">右子树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top></span><span style="COLOR: #000000">}</span></span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img id=_247_257_Open_Image onclick="this.style.display='none'; document.getElementById('_247_257_Open_Text').style.display='none'; document.getElementById('_247_257_Closed_Image').style.display='inline'; document.getElementById('_247_257_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_247_257_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_247_257_Closed_Text').style.display='none'; document.getElementById('_247_257_Open_Image').style.display='inline'; document.getElementById('_247_257_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_247_257_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id=_247_257_Open_Text><span style="COLOR: #808080">///</span><span style="COLOR: #008000">全局变量</span><span style="COLOR: #808080">///</span></span><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;g_Path;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">路径栈</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">vector</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">TreeNode</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;g_Heap;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">用于构造树的堆</span><span style="COLOR: #008000"><br><img id=_320_333_Open_Image onclick="this.style.display='none'; document.getElementById('_320_333_Open_Text').style.display='none'; document.getElementById('_320_333_Closed_Image').style.display='inline'; document.getElementById('_320_333_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_320_333_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_320_333_Closed_Text').style.display='none'; document.getElementById('_320_333_Open_Image').style.display='inline'; document.getElementById('_320_333_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_320_333_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id=_320_333_Open_Text><span style="COLOR: #808080">////////////</span><span style="COLOR: #008000">/</span><span style="COLOR: #808080"></span></span><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000">&nbsp;UDGreater(TreeNode&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">a,TreeNode&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">b)<br><img id=_376_479_Open_Image onclick="this.style.display='none'; document.getElementById('_376_479_Open_Text').style.display='none'; document.getElementById('_376_479_Closed_Image').style.display='inline'; document.getElementById('_376_479_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_376_479_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_376_479_Closed_Text').style.display='none'; document.getElementById('_376_479_Open_Image').style.display='inline'; document.getElementById('_376_479_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_376_479_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_376_479_Open_Text><span style="COLOR: #000000">{&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">为TreeNode定义一种比较大小的函数，以便后面构造小根堆</span><span style="COLOR: #008000"><br><img id=_433_451_Open_Image onclick="this.style.display='none'; document.getElementById('_433_451_Open_Text').style.display='none'; document.getElementById('_433_451_Closed_Image').style.display='inline'; document.getElementById('_433_451_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_433_451_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_433_451_Closed_Text').style.display='none'; document.getElementById('_433_451_Open_Image').style.display='inline'; document.getElementById('_433_451_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(a.Weight</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">b.Weight)</span><span id=_433_451_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_433_451_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img id=_458_477_Open_Image onclick="this.style.display='none'; document.getElementById('_458_477_Open_Text').style.display='none'; document.getElementById('_458_477_Closed_Image').style.display='inline'; document.getElementById('_458_477_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_458_477_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_458_477_Closed_Text').style.display='none'; document.getElementById('_458_477_Open_Image').style.display='inline'; document.getElementById('_458_477_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span id=_458_477_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_458_477_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;printPath()<br><img id=_499_621_Open_Image onclick="this.style.display='none'; document.getElementById('_499_621_Open_Text').style.display='none'; document.getElementById('_499_621_Closed_Image').style.display='inline'; document.getElementById('_499_621_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_499_621_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_499_621_Closed_Text').style.display='none'; document.getElementById('_499_621_Open_Image').style.display='inline'; document.getElementById('_499_621_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_499_621_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_499_621_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">打印从根节点到当前叶子节点的路径，即huffman编码</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;vector</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">::iterator&nbsp;it;<br><img id=_603_619_Open_Image onclick="this.style.display='none'; document.getElementById('_603_619_Open_Text').style.display='none'; document.getElementById('_603_619_Closed_Image').style.display='inline'; document.getElementById('_603_619_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_603_619_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_603_619_Closed_Text').style.display='none'; document.getElementById('_603_619_Open_Image').style.display='inline'; document.getElementById('_603_619_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(it</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">g_Path.begin();it</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">g_Path.end();it</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)</span><span id=_603_619_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_603_619_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;*</span><span style="COLOR: #000000">it;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;CreateHuffmanTree()<br><img id=_649_1266_Open_Image onclick="this.style.display='none'; document.getElementById('_649_1266_Open_Text').style.display='none'; document.getElementById('_649_1266_Closed_Image').style.display='inline'; document.getElementById('_649_1266_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_649_1266_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_649_1266_Closed_Text').style.display='none'; document.getElementById('_649_1266_Open_Image').style.display='inline'; document.getElementById('_649_1266_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_649_1266_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_649_1266_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">构造Huffman树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;TreeNode&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">left,</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">right,parent;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;make_heap(g_Heap.begin(),g_Heap.end(),UDGreater);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">构造小根堆</span><span style="COLOR: #008000"><br><img id=_775_1264_Open_Image onclick="this.style.display='none'; document.getElementById('_775_1264_Open_Text').style.display='none'; document.getElementById('_775_1264_Closed_Image').style.display='inline'; document.getElementById('_775_1264_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_775_1264_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_775_1264_Closed_Text').style.display='none'; document.getElementById('_775_1264_Open_Image').style.display='inline'; document.getElementById('_775_1264_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(g_Heap.size()</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)</span><span id=_775_1264_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_775_1264_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;left</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;TreeNode();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;right</span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;TreeNode();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pop_heap(g_Heap.begin(),g_Heap.end(),UDGreater);<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">g_Heap.back();&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">取出最小的节点</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Heap.pop_back();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pop_heap(g_Heap.begin(),g_Heap.end(),UDGreater);<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">right</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">g_Heap.back();&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">取出第二小的节点</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Heap.pop_back();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.left</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">根据这两个节点生成一个新的节点</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.right</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">right;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.Weight</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">left</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Weight</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">right</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Weight;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.flag</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Heap.push_back(parent);<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push_heap(g_Heap.begin(),g_Heap.end(),UDGreater);</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">在堆中添加进去新生成的节点&nbsp;</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;TravelHuffmanTree(TreeNode&nbsp;parent)<br><img id=_1309_1660_Open_Image onclick="this.style.display='none'; document.getElementById('_1309_1660_Open_Text').style.display='none'; document.getElementById('_1309_1660_Closed_Image').style.display='inline'; document.getElementById('_1309_1660_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_1309_1660_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_1309_1660_Closed_Text').style.display='none'; document.getElementById('_1309_1660_Open_Image').style.display='inline'; document.getElementById('_1309_1660_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=_1309_1660_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_1309_1660_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">遍历huffman树，在此过程中输出叶节点的编码</span><span style="COLOR: #008000"><br><img id=_1381_1468_Open_Image onclick="this.style.display='none'; document.getElementById('_1381_1468_Open_Text').style.display='none'; document.getElementById('_1381_1468_Closed_Image').style.display='inline'; document.getElementById('_1381_1468_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_1381_1468_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_1381_1468_Closed_Text').style.display='none'; document.getElementById('_1381_1468_Open_Image').style.display='inline'; document.getElementById('_1381_1468_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(parent.left</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">NULL&nbsp;</span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000">&nbsp;parent.right</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">NULL)</span><span id=_1381_1468_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_1381_1468_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">如果是叶子节点</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">parent.flag</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">:</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printPath();&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">打印路径即huffman编码</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img id=_1475_1658_Open_Image onclick="this.style.display='none'; document.getElementById('_1475_1658_Open_Text').style.display='none'; document.getElementById('_1475_1658_Closed_Image').style.display='inline'; document.getElementById('_1475_1658_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_1475_1658_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_1475_1658_Closed_Text').style.display='none'; document.getElementById('_1475_1658_Open_Image').style.display='inline'; document.getElementById('_1475_1658_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">else</span><span id=_1475_1658_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_1475_1658_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Path.push_back(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);&nbsp;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TravelHuffmanTree(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">parent.left);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">遍历左子树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Path.pop_back();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Path.push_back(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TravelHuffmanTree(</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">parent.right);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">遍历右子树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Path.pop_back();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align=top><br><img id=_1673_2009_Open_Image onclick="this.style.display='none'; document.getElementById('_1673_2009_Open_Text').style.display='none'; document.getElementById('_1673_2009_Closed_Image').style.display='inline'; document.getElementById('_1673_2009_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=_1673_2009_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_1673_2009_Closed_Text').style.display='none'; document.getElementById('_1673_2009_Open_Image').style.display='inline'; document.getElementById('_1673_2009_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;main()</span><span id=_1673_2009_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_1673_2009_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;count</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;TreeNode&nbsp;temp;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">请输入字符的个数</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">count;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cout</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">请输入要编码的字符和它的权值，用空格隔开，如：a&nbsp;12.5</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&lt;&lt;</span><span style="COLOR: #000000">endl;<br><img id=_1804_1901_Open_Image onclick="this.style.display='none'; document.getElementById('_1804_1901_Open_Text').style.display='none'; document.getElementById('_1804_1901_Closed_Image').style.display='inline'; document.getElementById('_1804_1901_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=_1804_1901_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_1804_1901_Closed_Text').style.display='none'; document.getElementById('_1804_1901_Open_Image').style.display='inline'; document.getElementById('_1804_1901_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(count</span><span style="COLOR: #000000">--</span><span style="COLOR: #000000">)</span><span id=_1804_1901_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span><span id=_1804_1901_Open_Text><span style="COLOR: #000000">{<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cin</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">temp.flag</span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">temp.Weight;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp.left</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp.right</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">NULL;<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_Heap.push_back(temp);<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;CreateHuffmanTree();&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">创建huffman树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;TreeNode&nbsp;root</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">g_Heap.front();<br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;TravelHuffmanTree(root);&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">遍历huffman树</span><span style="COLOR: #008000"><br><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align=top></span><span style="COLOR: #000000">}</span></span></div>
</div>
&nbsp;<br></div>
<img src ="http://www.cppblog.com/ngaut/aggbug/40001.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-12-30 13:55 <a href="http://www.cppblog.com/ngaut/archive/2007/12/30/40001.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个简单的递归下降分析表达式的例子</title><link>http://www.cppblog.com/ngaut/archive/2007/12/25/39612.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 25 Dec 2007 11:36:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/12/25/39612.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/39612.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/12/25/39612.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/39612.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/39612.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 好友学习递归时无法理解用递归下降的方式分析表达式，所以写了个简单的例子，为了使代码尽可能简单，省略了此法分析模块，直接使用人脑分析的词法^_^由于好友不懂c++，所以这里虽然用的c++，但还是按照c的方式写的代码。#include&nbsp;&lt;vector&gt;#include&nbsp;&lt;iostream&gt;#include&nbsp;&lt;assert.h&gt;usi...&nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2007/12/25/39612.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/39612.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-12-25 19:36 <a href="http://www.cppblog.com/ngaut/archive/2007/12/25/39612.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编译boost库-用vc2005编译boost1.34.1 </title><link>http://www.cppblog.com/ngaut/archive/2007/11/19/36968.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Mon, 19 Nov 2007 13:08:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/11/19/36968.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/36968.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/11/19/36968.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/36968.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/36968.html</trackback:ping><description><![CDATA[<br>
<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
<div class="postTitle">&nbsp;&nbsp; 编译boost库-用vc2005编译boost1.34.1&nbsp;	</div>
//打开控制台窗口，请使用vs2005在开始菜单中的&#8220;Visual Studio Tools-&gt;Visual Studio 2005 命令提示&#8221;打开控制台，这样vc的的编译环境就设置好了。<br>//假设boost安装包的解压的目录为{BOOST_SRC}中。<br>//先编译出bjam.exe，它被用于安装boost库<br>cd {BOOST_SRC}\tools\build\jam_src<br>build.bat<br>//利用编译出的bjam.exe程序编译并安装boost库<br>cd {BOOST_SRC}<br>copy {BOOST_SRC}\tools\build\jam_src\bin.ntx86\bjam.exe<br>//下面的命令的各选项的说明：<br>//prefix&nbsp;&nbsp;&nbsp; 将boost安装到的路径（生成的头文件和库文件都会放到该路径中）。<br>//重定义以下变量（利用-s设置）：<br>//VC80_ROOT　　vc2005的安装路径，如果未将vc2005安装到默认位置，你必须指定该项。<br>//TOOLS&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;使用的编译工具，vc2005对应的是vc-8_0<br>//PYTHON_ROOT&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; python的安装目录，如果未将BOOST安装到默认位置，你必须指定该项。<br>//BUILD&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;编译结果选项，默认会生成尽可能多的版本，如调试版／发行版，静态库／动态库，单线程／多线程。<br>bjam
"-sVC80_ROOT=D:\Program Files\Microsoft Visual Studio 8\VC"
"-sTOOLS=vc-8_0"&nbsp; "-sPYTHON_ROOT=D:\Program Files\Python24"
"--prefix=E:\librarys\boost" install <br><img src ="http://www.cppblog.com/ngaut/aggbug/36968.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-11-19 21:08 <a href="http://www.cppblog.com/ngaut/archive/2007/11/19/36968.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何解决"找不到MSVCR80.dll "的问题</title><link>http://www.cppblog.com/ngaut/archive/2007/11/17/36786.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sat, 17 Nov 2007 04:06:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/11/17/36786.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/36786.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/11/17/36786.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/36786.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/36786.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2007/11/17/36786.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/36786.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-11-17 12:06 <a href="http://www.cppblog.com/ngaut/archive/2007/11/17/36786.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>boost asio发送0字节的数据时,接收端提示"找不到指定文件"</title><link>http://www.cppblog.com/ngaut/archive/2007/10/23/34937.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 23 Oct 2007 11:16:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/10/23/34937.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/34937.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/10/23/34937.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/34937.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/34937.html</trackback:ping><description><![CDATA[<p><br>asio点滴:</p>
<p>采用tcp连接发送数据时,如果发送的数据的size是0,那么接收端会提示"找不到指定文件"</p>
<img src ="http://www.cppblog.com/ngaut/aggbug/34937.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-10-23 19:16 <a href="http://www.cppblog.com/ngaut/archive/2007/10/23/34937.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>release版本的程序提示需要MFC42D.dll的原因</title><link>http://www.cppblog.com/ngaut/archive/2007/04/30/23246.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Mon, 30 Apr 2007 07:43:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/04/30/23246.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/23246.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/04/30/23246.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/23246.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/23246.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;release版本的程序中使用的DLL是debug版本的^_^
<img src ="http://www.cppblog.com/ngaut/aggbug/23246.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-04-30 15:43 <a href="http://www.cppblog.com/ngaut/archive/2007/04/30/23246.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>boost::asio异步tcp传送文件的源代码</title><link>http://www.cppblog.com/ngaut/archive/2007/04/12/21715.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Thu, 12 Apr 2007 06:20:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/04/12/21715.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/21715.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/04/12/21715.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/21715.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/21715.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2007/04/12/21715.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/21715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-04-12 14:20 <a href="http://www.cppblog.com/ngaut/archive/2007/04/12/21715.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UDP局域网广播的问题</title><link>http://www.cppblog.com/ngaut/archive/2007/04/11/21676.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Wed, 11 Apr 2007 15:04:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/04/11/21676.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/21676.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/04/11/21676.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/21676.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/21676.html</trackback:ping><description><![CDATA[<p>客户端和服务端使用相同的端口，通讯方式：服务端采用广播，客户端单播。<br></p>
<p>广播出去的包服务端自己也会收到一份，需要过滤(可以通过检测IP)，麻烦，貌似对效率有一点小小的影响，更好的方法是客户端和服务端使用不同的端口。<br>如服务端监听67端口，客户端监听68端口，服务端广播的包是发到67端口的，故监听68端口就不会收到自己发的广播包了^_^</p>
<img src ="http://www.cppblog.com/ngaut/aggbug/21676.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-04-11 23:04 <a href="http://www.cppblog.com/ngaut/archive/2007/04/11/21676.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>看了两天boost::asio网络库相关的资料，写了个小程序用异步tcp方式来传文件，果然高效，速度稳定在10M/s左右</title><link>http://www.cppblog.com/ngaut/archive/2007/04/10/21612.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 10 Apr 2007 12:09:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/04/10/21612.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/21612.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/04/10/21612.html#Feedback</comments><slash:comments>13</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/21612.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/21612.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2007/04/10/21612.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/21612.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-04-10 20:09 <a href="http://www.cppblog.com/ngaut/archive/2007/04/10/21612.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vc++2005 boost 相关 </title><link>http://www.cppblog.com/ngaut/archive/2007/04/06/21365.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Thu, 05 Apr 2007 16:40:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/04/06/21365.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/21365.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/04/06/21365.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/21365.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/21365.html</trackback:ping><description><![CDATA[<p>输入命令行参数的地方：</p>
<p>项目：属性：配置属性：调试：命令参数<br><br></p>
<p>建议预处理器中加入宏BOOST_ALL_NO_LIB避免一些问题</p>
<p>&nbsp;</p>
<img src ="http://www.cppblog.com/ngaut/aggbug/21365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-04-06 00:40 <a href="http://www.cppblog.com/ngaut/archive/2007/04/06/21365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决unresolved external symbol "public: int __thiscall CWnd::KillTimer(unsigned int)" (?KillTimer@CWnd@@QAEHI@Z)问题</title><link>http://www.cppblog.com/ngaut/archive/2007/02/23/18933.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 23 Feb 2007 15:48:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/02/23/18933.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/18933.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/02/23/18933.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/18933.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/18933.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 解决KillTimer link失败的问题&nbsp;&nbsp;<a href='http://www.cppblog.com/ngaut/archive/2007/02/23/18933.html'>阅读全文</a><img src ="http://www.cppblog.com/ngaut/aggbug/18933.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-02-23 23:48 <a href="http://www.cppblog.com/ngaut/archive/2007/02/23/18933.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]Google Talk library – libjingle 测试笔记</title><link>http://www.cppblog.com/ngaut/archive/2007/02/09/18568.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 09 Feb 2007 01:32:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/02/09/18568.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/18568.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/02/09/18568.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/18568.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/18568.html</trackback:ping><description><![CDATA[
		<h4 class="TextColor1" id="subjcns!ECCDDFB2EC6A263!128" style="MARGIN-BOTTOM: 0px">转自：<a href="http://readingmemos.spaces.live.com/blog/cns!ECCDDFB2EC6A263!128.entry">http://readingmemos.spaces.live.com/blog/cns!ECCDDFB2EC6A263!128.entry</a></h4>
		<h4 class="TextColor1" style="MARGIN-BOTTOM: 0px">Google Talk library – libjingle 测试笔记</h4>
		<div id="msgcns!ECCDDFB2EC6A263!128">
				<ol>
						<li>下载 
<p>http://prdownloads.sourceforge.net/libjingle/libjingle-0.3.0.zip?download </p></li>
						<li>下载expat XML Parser 
<p>http://sourceforge.net/project/showfiles.php?group_id=10127&amp;package_id=11277 </p></li>
						<li>Install expat 
</li>
						<li>Open the libjingle.sln 
</li>
						<li>Add lib path expat-VERSION\StaticLibs 
</li>
						<li>Add include path: expat-VERSION\Source\Lib 
</li>
						<li>Goto <a href="http://developer.globalipsound.com/"><font color="#006629">http://developer.globalipsound.com</font></a></li>
						<li>Registrer first 
</li>
						<li>Download 
</li>
						<li>unzip and put it into third_party\gips\Interface 
</li>
						<li>modify the expiration.h 
</li>
						<li>build 
</li>
						<li>if has error: has no netfw.h, download from SDK, or just from <a href="http://www.codeproject.com/w2k/WinXPSP2Firewall.asp"><font color="#006629">http://www.codeproject.com/w2k/WinXPSP2Firewall.asp</font></a></li>
						<li>
						</li>
				</ol>
		</div>
<img src ="http://www.cppblog.com/ngaut/aggbug/18568.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-02-09 09:32 <a href="http://www.cppblog.com/ngaut/archive/2007/02/09/18568.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]OnDraw()和OnPaint()兄弟</title><link>http://www.cppblog.com/ngaut/archive/2007/02/06/18476.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 06 Feb 2007 08:41:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/02/06/18476.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/18476.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/02/06/18476.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/18476.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/18476.html</trackback:ping><description><![CDATA[
		<table style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" cellspacing="0" cellpadding="0" width="90%" border="0">
				<tbody>
						<tr>
								<td class="oblog_t_4">
										<span class="style1">
												<font size="3">OnDraw()和OnPaint()兄弟</font>
										</span>
								</td>
						</tr>
						<tr>
								<td>
										<table cellspacing="0" cellpadding="0" width="100%" border="0">
												<tbody>
														<tr>
																<td>
																		<div align="right">
																				<span class="oblog_text">
																				</span> </div>
																</td>
														</tr>
												</tbody>
										</table>
										<span class="oblog_text">
												<br />
												<br />
												<br />经常有朋友问雷神这样的问题：<br />我在视图画的图象或者文字，当窗口改变后为什么不见了？<br />OnDraw()和OnPaint()两个都是解决上面的问题，有什么不同？<br /><br />雷神在这里一并解答一下吧。<br />OnDraw()和OnPaint()好象兄弟俩，因为它们的工作类似。<br /><br />至于不见了的问题简单，因为当你的窗口改变后，会产生无效区域，这个无效的区域需要重画。一般Windows回发送两个消息WM_PAINT（通知客户区有变化）和WM_NCPAINT（通知非客户区有变化）。非客户区的重画系统自己搞定了，而客户区的重画需要我们自己来完成。这就需要OnDraw()或OnPaint()来重画窗口。<br /><br />OnDraw()和OnPaint()有什么区别呢？<br />首先：<br />我们先要明确CView类派生自CWnd类。而OnPaint()是CWnd的类成员，同时负责响应WM_PAINT消息。OnDraw()是CVIEW的成员函数，并且没有响应消息的功能。这就是为什么你用VC成的程序代码时，在视图类只有OnDraw没有OnPaint的原因。<br /><br />其次：<br />我们在第《每天跟我学MFC》3的开始部分已经说到了。要想在屏幕上绘图或显示图形，首先需要建立设备环境DC。其实DC是一个数据结构，它包含输出设备（不单指你17寸的纯屏显示器，还包括打印机之类的输出设备）的绘图属性的描述。MFC提供了CPaintDC类和CWindwoDC类来实时的响应，而CPaintDC支持重画。<br /><br />当视图变得无效时（包括大小的改变，移动，被遮盖等等），Windows 将 WM_PAINT 消息发送给它。该视图的 OnPaint 处理函数通过创建 CPaintDC 类的DC对象来响应该消息并调用视图的 OnDraw 成员函数。通常我们不必编写重写的 OnPaint 处理成员函数。<br /><br />///CView默认的标准的重画函数<br />void CView::OnPaint()<br />{<br />    CPaintDC dc(this);<br />    OnPreparDC(&amp;dc)；<br />    OnDraw(&amp;dc); //调用了OnDraw<br />}<br /><br />既然OnPaint最后也要调用OnDraw,因此我们一般会在OnDraw函数中进行绘制。下面是一个典型的程序<br /><br />///视图中的绘图代码首先检索指向文档的指针，然后通过DC进行绘图调用。<br />void CMyView::OnDraw( CDC* pDC )<br />{<br />    CMyDoc* pDoc = GetDocument();<br />    CString s = pDoc-&gt;GetData();   // Returns a CString<br />    CRect rect;<br /><br />    GetClientRect( &amp;rect );<br />    pDC-&gt;SetTextAlign( TA_BASELINE | TA_CENTER );<br />    pDC-&gt;TextOut( rect.right / 2, rect.bottom / 2, <br />                  s, s.GetLength() );<br />}<br /><br />最后：<br />现在大家明白这哥俩之间的关系了吧。因此我们一般用OnPaint维护窗口的客户区（例如我们的窗口客户区加一个背景图片），用OnDraw维护视图的客户区（例如我们通过鼠标在视图中画图）。当然你也可以不按照上面规律来，只要达到目的并且没有问题，怎么干都成。<br /><br />补充：<br />我们还可以利用Invalidate(),ValidateRgn(),ValidateRect()函数强制的重画窗口，具体的请参考MSDN吧。<br /></span>
								</td>
						</tr>
				</tbody>
		</table>
<img src ="http://www.cppblog.com/ngaut/aggbug/18476.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-02-06 16:41 <a href="http://www.cppblog.com/ngaut/archive/2007/02/06/18476.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>miscellaneous的一个代码文件,使用了一些移植技巧和常用的技巧,记录之,备用</title><link>http://www.cppblog.com/ngaut/archive/2007/02/04/18322.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sun, 04 Feb 2007 07:19:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2007/02/04/18322.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/18322.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2007/02/04/18322.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/18322.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/18322.html</trackback:ping><description><![CDATA[
		<p> </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"> misc.h - miscellaneous interfaces </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> SimpleScalar(TM) Tool Suite<br /> * Copyright (C) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC.<br /> * All Rights Reserved. <br /> * <br /> * THIS IS A LEGAL DOCUMENT, BY USING SIMPLESCALAR,<br /> * YOU ARE AGREEING TO THESE TERMS AND CONDITIONS.<br /> * <br /> * No portion of this work may be used by any commercial entity, or for any<br /> * commercial purpose, without the prior, written permission of SimpleScalar,<br /> * LLC (info@simplescalar.com). Nonprofit and noncommercial use is permitted<br /> * as described below.<br /> * <br /> * 1. SimpleScalar is provided AS IS, with no warranty of any kind, express<br /> * or implied. The user of the program accepts full responsibility for the<br /> * application of the program and the use of any results.<br /> * <br /> * 2. Nonprofit and noncommercial use is encouraged. SimpleScalar may be<br /> * downloaded, compiled, executed, copied, and modified solely for nonprofit,<br /> * educational, noncommercial research, and noncommercial scholarship<br /> * purposes provided that this notice in its entirety accompanies all copies.<br /> * Copies of the modified software can be delivered to persons who use it<br /> * solely for nonprofit, educational, noncommercial research, and<br /> * noncommercial scholarship purposes provided that this notice in its<br /> * entirety accompanies all copies.<br /> * <br /> * 3. ALL COMMERCIAL USE, AND ALL USE BY FOR PROFIT ENTITIES, IS EXPRESSLY<br /> * PROHIBITED WITHOUT A LICENSE FROM SIMPLESCALAR, LLC (info@simplescalar.com).<br /> * <br /> * 4. No nonprofit user may place any restrictions on the use of this software,<br /> * including as modified by the user, by any other authorized user.<br /> * <br /> * 5. Noncommercial and nonprofit users may distribute copies of SimpleScalar<br /> * in compiled or executable form as set forth in Section 2, provided that<br /> * either: (A) it is accompanied by the corresponding machine-readable source<br /> * code, or (B) it is accompanied by a written offer, with no time limit, to<br /> * give anyone a machine-readable copy of the corresponding source code in<br /> * return for reimbursement of the cost of distribution. This written offer<br /> * must permit verbatim duplication by anyone, or (C) it is distributed by<br /> * someone who received only the executable form, and is accompanied by a<br /> * copy of the written offer of source code.<br /> * <br /> * 6. SimpleScalar was developed by Todd M. Austin, Ph.D. The tool suite is<br /> * currently maintained by SimpleScalar LLC (info@simplescalar.com). US Mail:<br /> * 2395 Timbercrest Court, Ann Arbor, MI 48105.<br /> * <br /> * Copyright (C) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC.<br /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />工具函数文件<br /><br />这个文件定义了一些通用的工具函数<br /><br />@file misc.h<br />@author www.simplescalar.com(编写)<br />@author xieyubo@gmail.com(中文注释)<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifndef MISC_H<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> MISC_H</span>
				<span style="COLOR: #000000">
						<br />
						<br />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdio.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdlib.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">stdarg.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #0000ff">string</span>
				<span style="COLOR: #000000">.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />#include </span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #000000">sys</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">types.h</span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> boolean value defs </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义一些bool值</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #000000">#ifndef TRUE<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> TRUE 1</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />#ifndef FALSE<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> FALSE 0</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> various useful macros </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义求最大数的宏</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #000000">#ifndef MAX<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> MAX(a, b)    (((a) &lt; (b)) ? (b) : (a))</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义求最小数的宏</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #000000">#ifndef MIN<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> MIN(a, b)    (((a) &lt; (b)) ? (a) : (b))</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> for printing out "long long" vars </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 获得long long的高32位</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> LLHIGH(L)        ((int)(((L)&gt;&gt;32) &amp; 0xffffffff))</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 获得long long的低32位</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> LLLOW(L)        ((int)((L) &amp; 0xffffffff))</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> size of an array, in elements </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 获和数组中元素的个数</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> N_ELT(ARR)   (sizeof(ARR)/sizeof((ARR)[0]))</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> rounding macros, assumes ALIGN is a power of two </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 向上取整</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> ROUND_UP(N,ALIGN)    (((N) + ((ALIGN)-1)) &amp; ~((ALIGN)-1))</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 向下取整</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> ROUND_DOWN(N,ALIGN)    ((N) &amp; ~((ALIGN)-1))</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> verbose output flag </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 详细信息输出标志</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">extern</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> verbose;<br /><br />#ifdef DEBUG<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> active debug flag </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 调试标志</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">extern</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> debugging;<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* DEBUG */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> register a function to be called when an error is detected </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 注册一个出错处理函数</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />fatal_hook(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">hook_fn)(FILE </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">stream));    </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> fatal hook function </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> declare a fatal run-time error, calls fatal hook function </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义错误处理的宏</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> fatal(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)    \</span>
				<span style="COLOR: #000000">
						<br />  _fatal(__FILE__, __FUNCTION__, __LINE__, fmt, ## args)<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />_fatal(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">file, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">func, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> line, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />)<br />__attribute__ ((noreturn));<br /></span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />fatal(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> declare a panic situation, dumps core </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义一个错误处理函数, 会直接调用abort()终止程序</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> panic(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)    \</span>
				<span style="COLOR: #000000">
						<br />  _panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## args)<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />_panic(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">file, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">func, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> line, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />)<br />__attribute__ ((noreturn));<br /></span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />panic(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> declare a warning </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 定义一个警告函数</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> warn(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)    \</span>
				<span style="COLOR: #000000">
						<br />  _warn(__FILE__, __FUNCTION__, __LINE__, fmt, ## args)<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />_warn(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">file, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">func, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> line, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />warn(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> print general information </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 打印通用的信息</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> info(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)    \</span>
				<span style="COLOR: #000000">
						<br />  _info(__FILE__, __FUNCTION__, __LINE__, fmt, ## args)<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />_info(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">file, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">func, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> line, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />info(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef DEBUG<br /><br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> print a debugging message </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 打印调试信息</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> debug(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)    \</span>
				<span style="COLOR: #000000">
						<br />    </span>
				<span style="COLOR: #0000ff">do</span>
				<span style="COLOR: #000000"> {                        \<br />        </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (debugging)             \<br />            _debug(__FILE__, __FUNCTION__, __LINE__, fmt, ## args); \<br />    } </span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">)<br /><br /></span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />_debug(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">file, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">func, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> line, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />debug(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />);<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !DEBUG */</span>
				<span style="COLOR: #000000">
						<br />
						<br />#ifdef __GNUC__<br /></span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> debug(fmt, args<img src="http://www.cppblog.com/images/dot.gif" />)</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#else</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> the optimizer should eliminate this call! </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> debug(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fmt, <img src="http://www.cppblog.com/images/dot.gif" />) {}<br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !__GNUC__ */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* !DEBUG */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> seed the random number generator </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 设定随机数种子</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">
						<br />mysrand(unsigned </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> seed);    </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> random number generator seed </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> get a random number </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #808080">///</span>
				<span style="COLOR: #008000"> 产生一个随机数</span>
				<span style="COLOR: #808080">
						<br />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> myrand(</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000">);        </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> returns random number </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> copy a string to a new storage allocation (NOTE: many machines are missing<br />   this trivial function, so I funcdup() it here<img src="http://www.cppblog.com/images/dot.gif" />) </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />复制一个新的字符串<br /><br />@param[in] s 待复制的字符串<br />@return 返回复制的字符串指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">                </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> duplicated string </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />mystrdup(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s);        </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> string to duplicate to heap storage </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> find the last occurrence of a character in a string </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />查找一个字符在字符串中最后出现的位置<br /><br />@param[in] s 原字符串<br />@param[in] c 待查找的字符<br />@return 指向待查找字符位置的字符串指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">
						<br />mystrrchr(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> c);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> case insensitive string compare (NOTE: many machines are missing this<br />   trivial function, so I funcdup() it here<img src="http://www.cppblog.com/images/dot.gif" />) </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />对两个字符串进行大小写无关的比较<br /><br />@param[in] s1 待比较的字符串1<br />@param[in] s2 待比较的字符串2<br />@retval &lt;0 s1小于s2<br />@retval =0 s1等于s2<br />@retval &gt;0 s1大于s2<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">                </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> compare result, see strcmp() </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />mystricmp(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s1, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s2);    </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> strings to compare, case insensitive </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> allocate some core, this memory has overhead no larger than a page<br />   in size and it cannot be released. the storage is returned cleared </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />分配指定大小的内存<br /><br />@param[in] nbytes 指定的字节数<br />@return 分配的内存的指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">getcore(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> nbytes);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> return log of a number to the base 2 </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />计算log2<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> log_base2(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> n);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> return string describing elapsed time, passed in SEC in seconds </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />构造一个描述耗时多少的字符串<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">elapsed_time(</span>
				<span style="COLOR: #0000ff">long</span>
				<span style="COLOR: #000000"> sec);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />从指定的32位的数中截取出指定长度的位数<br /><br />@param[in] word 指定的32位数<br />@param[in] pos 开始截中的位置<br />@param[in] num 指定的长度<br />@return 返回所截取出来的位数<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> assume bit positions numbered 31 to 0 (31 high order bit), extract num bits<br />   from word starting at position pos (with pos as the high order bit of those<br />   to be extracted), result is right justified and zero filled to high order<br />   bit, for example, extractl(word, 6, 3) w/ 8 bit word = 01101011 returns<br />   00000110 </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />unsigned </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000">
						<br />extractl(</span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> word,        </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> the word from which to extract </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />         </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> pos,        </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> bit positions 31 to 0 </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />         </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> num);        </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> number of bits to extract </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #0000ff">#if</span>
				<span style="COLOR: #000000"> defined(sparc) &amp;&amp; !defined(__svr4__)</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#define</span>
				<span style="COLOR: #000000"> strtoul strtol</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> portable 64-bit I/O package </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> portable vsprintf with qword support, returns end pointer </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />输出格式化字符串到缓冲区中<br /><br />@param[in] obuf 缓冲区<br />@param[in] format 格式<br />@param[in] v 参数<br />@return 缓冲区中字符串结束的指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000"> <br /></span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">myvsprintf(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">obuf, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">format, va_list v);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> portable sprintf with qword support, returns end pointer </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />输出格式化字符串到缓冲区中<br /><br />@param[in] obuf 缓冲区<br />@param[in] format 格式<br />@param[in] <img src="http://www.cppblog.com/images/dot.gif" /> 参数<br />@return 缓冲区中字符串结束的指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">mysprintf(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">obuf, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">format, <img src="http://www.cppblog.com/images/dot.gif" />);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> portable vfprintf with qword support, returns end pointer </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />输出格式化字符串到文件中<br /><br />@param[in] stream 文件指针<br />@param[in] format 格式<br />@param[in] v 参数<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> myvfprintf(FILE </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">stream, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">format, va_list v);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> portable fprintf with qword support, returns end pointer </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />输出格式化字符串到文件中<br /><br />@param[in] stream 文件指针<br />@param[in] format 格式<br />@param[in] <img src="http://www.cppblog.com/images/dot.gif" /> 参数<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> myfprintf(FILE </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">stream, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">format, <img src="http://www.cppblog.com/images/dot.gif" />);<br /><br />#ifdef HOST_HAS_QWORD<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> convert a string to a signed result </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />sqword_t myatosq(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">nptr, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">**</span>
				<span style="COLOR: #000000">endp, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">base</span>
				<span style="COLOR: #000000">);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> convert a string to a unsigned result </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />qword_t myatoq(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">nptr, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">**</span>
				<span style="COLOR: #000000">endp, </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">base</span>
				<span style="COLOR: #000000">);<br /><br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* HOST_HAS_QWORD */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> same semantics as fopen() except that filenames ending with a ".gz" or ".Z"<br />   will be automagically get compressed </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />打开文件<br /><br />如果文件以".gz"或".Z"结尾, 则其中自解压功能<br /><br />@param[in] fname 待打开的文件名<br />@param[in] type 打开方式<br />@return 打开后的文件指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />FILE </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">gzopen(</span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fname, </span>
				<span style="COLOR: #0000ff">char</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">type);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> close compressed stream </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />关闭文件<br /><br />@param[in] fd 待关闭的文件指针<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> gzclose(FILE </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">fd);<br /><br /></span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000"> update the CRC on the data block one byte at a time </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
				</span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">*<br />对数据块进行CRC效验<br /><br />其中word_t被定义为了unsigned int<br /></span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />word_t crc(word_t crc_accum, word_t data);<br /><br /></span>
				<span style="COLOR: #0000ff">#endif</span>
				<span style="COLOR: #000000"> /* MISC_H */</span>
				<span style="COLOR: #000000">
						<br />
						<br />
				</span>
		</div>
<img src ="http://www.cppblog.com/ngaut/aggbug/18322.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2007-02-04 15:19 <a href="http://www.cppblog.com/ngaut/archive/2007/02/04/18322.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一点收获：CreateProcess的第一个参数最好使用绝对路径</title><link>http://www.cppblog.com/ngaut/archive/2006/12/01/15857.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 01 Dec 2006 09:59:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/12/01/15857.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/15857.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/12/01/15857.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/15857.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/15857.html</trackback:ping><description><![CDATA[
		<p>最近的一个项目里面出现了一个bug，开始的时候能够成功的创建进程，而后来执行某个操作之后就无法创建成功了，GetLastError()返回的结果是找不到文件，这就奇怪了。为什么开始的时候能找到，而后来找不到呢?<br /><br />还不清楚什么原因，所以变通一下，改成绝对路径，搞定</p>
<img src ="http://www.cppblog.com/ngaut/aggbug/15857.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-12-01 17:59 <a href="http://www.cppblog.com/ngaut/archive/2006/12/01/15857.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vc7编译boost 1.33.1记录</title><link>http://www.cppblog.com/ngaut/archive/2006/11/14/15141.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Mon, 13 Nov 2006 17:25:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/11/14/15141.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/15141.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/11/14/15141.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/15141.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/15141.html</trackback:ping><description><![CDATA[编译了几次终于成功了，简单记下过程，以免以后又忘了^_^<br /><br />在Visual Studio .NET 2003 命令提示下进入boost目录，如何进入tools\build\jam_src\，执行build.bat，编译成功得到bjam.exe<br /><br />接着copy bjam.exe到 boost目录，执行bjam -sBOOST_ROOT=. -sTOOLS=vc7 "-sBUILD=debug release &lt;runtime-link&gt;static/dynamic"<br /><br />漫长的等待后会在boost目录下的bin文件夹中生产一堆lib,复制到sdk的lib路径下，将boost目录添加的工程中。ok<br /><br /><br /><br />上面是偶的经历，如果你不能编译成功，请参考下面的文章<br /><br />原文出自：<a href="http://unknown-error.spaces.live.com/blog/cns!9B12A9BDE11A3428!142.entry#comment">http://unknown-error.spaces.live.com/blog/cns!9B12A9BDE11A3428!142.entry#comment</a><br /><br /><br /><br /><h4 class="TextColor1" id="subjcns!9B12A9BDE11A3428!142" style="MARGIN-BOTTOM: 0px">如何开始使用boost的跨平台thread库(Windows)</h4><div id="msgcns!9B12A9BDE11A3428!142"><div><font size="3">boost主页：</font><a href="http://www.boost.org/"><font color="#0066a7" size="3">http://www.boost.org/</font></a></div><div><font size="3">在主页点击download进入sourceforge页面下载，当前最新版本为boost_1_33_1，有多种文件格式可供下载(包括.exe, .tar.gz等)，内容相同，都是boost_1_33_1的全部源代码。下载后解压(假设解压目录为D:\boost\boost_1_33_1)。</font></div><div><font size="3"></font> </div><div><font size="3">boost中的大部分内容都可以直接源代码使用，而thread则需要首先编译出对应的库。</font></div><div><font size="3"></font> </div><div><strong><font size="3">Windows XP平台：</font></strong></div><div><font size="3">      我的机器上安装了vc2003和vc2005，分别在D:\devenv\vs2003和D:\devenv\vs2005目录下</font></div><div><font size="3"><strong>1. 编译jam（JAM是编译其他库的基础）<br /></strong>启动命令行进入D:\boost\boost_1_33_1\tools\build\jam_src目录</font></div><div><font size="3">运行build即可</font></div><div><font size="3">运行结束后，将新出现bin.ntx86目录，我们所需要的bjam.exe就在该目录下。</font></div><div><font size="3"></font> </div><div><font size="3">查看一下build文件的内容，发现其自动检测vc2003(vc7.1)的安装目录，然后调用vc7.1编译出的bjam.exe。（使用了VS71COMNTOOLS宏）</font></div><div><font size="3"></font> </div><div><strong><font size="3">2. 编译thread库</font></strong></div><div><font size="3">启动命令行进入D:\boost\boost_1_33_1目录</font></div><div><font size="3">set VC71_ROOT=D:\devenv\vs2003\Vc7  (此时没有自动检测，所以需要人工指定)</font></div><div><font size="3">tools\build\jam_src\bin.ntx86\bjam.exe --with-thread stage (只编译thread库)</font></div><div><font size="3"></font> </div><div><font size="3">编译完成后，结果在D:\boost\boost_1_33_1\bin\boost\libs\thread\build目录下（包括debug/relase, dll/lib等）；另外，由于我们在编译时使用了stage选项，所以所有的结果都将被拷贝到D:\boost\boost_1_33_1\stage\lib目录下。</font></div><div><font size="3"></font> </div><div><font size="3">总结一下，</font></div><div>动态库<br />libboost_thread-vc71-mt-gd-1_33_1.lib  +  boost_thread-vc71-mt-gd-1_33_1.dll (debug)      42.4k + 88.0k<br />libboost_thread-vc71-mt-1_33_1.lib     +  boost_thread-vc71-mt-1_33_1.dll    (release)    42.0k + 44.0k</div><div>静态库<br />libboost_thread-vc71-mt-gd-1_33_1.lib  (debug)    2.61M<br />libboost_thread-vc71-mt-1_33_1.lib     (release)  782k</div><div>静态库(runtime-link-static)<br />libboost_thread-vc71-mt-sgd-1_33_1.lib (debug)    2.19M<br />libboost_thread-vc71-mt-s-1_33_1.lib   (release)  692k</div><div><br />s Static link to runtime. <br />g Debug runtime. <br />d Debug enabled code. </div><div> </div><div><font size="3"></font> </div><div><strong><font size="3">3. 准备使用thread库</font></strong></div><div><font size="3">    选用编译得到的thread动态库。</font></div><div><font size="3">    将boost_thread-vc71-mt-gd-1_33_1.lib重命名为libboost_thread-vc71-mt-gd-1_33_1.lib(前面加了lib)</font></div><div><font size="3">    将boost_thread-vc71-mt-1_33_1.lib重命名为libboost_thread-vc71-mt-1_33_1.lib(前面加了lib)</font></div><div><font size="3">    将这两个文件拷贝到D:\devenv\vs2003\Vc7\PlatformSDK\Lib</font></div><div><font size="3"></font> </div><div><font size="3">    将boost_thread-vc71-mt-gd-1_33_1.dll拷贝到windows的system32目录下</font></div><div><font size="3">    将boost_thread-vc71-mt-1_33_1.dll拷贝到windows的system32目录下</font></div><div><font size="3"></font> </div><div><font size="3">以上将thread的debug/release版本的共享库拷贝到系统目录下，接下去就可以使用了。</font></div><div><font size="3"></font> </div><div><strong><font size="3">4. 使用thread库</font></strong></div><div><font size="3">    在vc2003中创建一个空的Win32 Console Project，代码：</font></div><div><font size="3">#include &lt;boost/thread/thread.hpp&gt;<br />#include &lt;iostream&gt;</font></div><div><font size="3">void hello()<br />{<br />    std::cout &lt;&lt; "Hello world, I'm a thread!" &lt;&lt; std::endl;<br />}</font></div><div><font size="3">main()<br />{<br />    boost::thread thrd(&amp;hello);<br />    thrd.join();<br />}</font></div><div><font size="3"></font> </div><div><font size="3">    设置Project属性的Code Geneartion------Runtime Library 为 /MDd 或者 /MD</font></div><div><font size="3">    设置Project属性的General-------Additional Include Directories为 D:\boost\boost_1_33_1</font></div><div><font size="3"></font> </div><div><font size="3">    编译运行即可。</font></div><br /></div><img src ="http://www.cppblog.com/ngaut/aggbug/15141.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-11-14 01:25 <a href="http://www.cppblog.com/ngaut/archive/2006/11/14/15141.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]CreateProcess创建的子进程的命令行参数</title><link>http://www.cppblog.com/ngaut/archive/2006/11/10/14968.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 10 Nov 2006 08:01:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/11/10/14968.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/14968.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/11/10/14968.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/14968.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/14968.html</trackback:ping><description><![CDATA[
		<div class="tit">CreateProcess创建的子进程的命令行参数</div>
		<div class="date">2006-10-17 08:13</div>
		<table style="TABLE-LAYOUT: fixed">
				<tbody>
						<tr>
								<td>
										<div class="cnt">
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">用</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">创</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">建的子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程所</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">获</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">得的命令行参数有以下几</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">种</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">情况：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<?XML:NAMESPACE PREFIX = O /?>
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">1</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">．子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">WinMain</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">函数的第三个参数</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">lpCmdLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">表示的命令行参数中除去</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">应</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">用程序路径、文件名以及与参数相隔的空格等字符串后的内容。比如</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">程：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess(NULL, “c:\\test.exe -p“, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">lpCmdLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">-p,</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">注意没有双引号</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN"> <o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">2</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">．如果通</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">过</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">lpCmdLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">查</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">看命令行参数，</span>
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">那</span>
														</font>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">么</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">创</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">建子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程的</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">时</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">候，需要在子程序和参数中加上空格号。比如：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">程：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess(“c:\\test.exe”</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">“ -p“, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">lpCmdLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">-p</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">，没有空格了。</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN"> <o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">3</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">．如果想</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">获</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">得子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程的完整命令行参数，</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">调</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">用</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">函数。通常通</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">过</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">函数</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">获</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">得的命令行参数，是父</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">调</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">用</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">时</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">的完整参数。</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">CreateProcess(NULL, “c:\\test.exe -p“, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">返回的参数</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">c:\\test.exe -p,</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">注意没有双引号</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial"> <o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">以下情况都是</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">调</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">用</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">函数</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">获</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">得命令行参数</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">4</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">．</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">CreateProcess</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">第一个参数是</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">NULL</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">，第二个参数指定子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">应</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">用程序和命令行参数，那</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">么</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程的命令行参数是第二个参数，不</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">带</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">双引号。比如：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">程：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">CreateProcess(NULL, “c:\\test.exe -p“, NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">获</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">得的命令行参数</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">c:\\test.exe -p<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial"> <o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">5</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">．</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">第一个参数指定子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">应</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">用程序路径和文件名，第二个参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">NULL</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">，那</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">么</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程的命令行参数是第一个参数，</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">带</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">双引号。</span>
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">比如：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<font face="ＭＳ Ｐゴシック">
																<span style="FONT-SIZE: 10.5pt; COLOR: #111111">程：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">CreateProcess(“c:\\test.exe“, NULL</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial"> NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">进</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">GetCommandLine</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">获</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111">
																<font face="ＭＳ Ｐゴシック">得的命令行参数</font>
														</span>
														<span style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial">”c:\\test.exe“<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial"> <o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">6</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">．</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">第一个参数指定子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">应</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">用程序路径和文件名，第二个参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">为传递给</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程的参数，那</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">么</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程的命令行参数是第二个参数，不</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">带</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">双引号。比如：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">父</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">程：</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">CreateProcess(“c:\\test.exe“, ”-p“</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN"> NULL, NULL, FALSE, 0, NULL, NULL, &amp;si, &amp;pi);<o:p></o:p></span>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">子</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">进</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">程中，</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">GetCommandLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">获</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">得的命令行参数</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">为</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">-p</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">。</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
												<p style="BACKGROUND: white; LINE-HEIGHT: 18pt">
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">此</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">处</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">注意同第二点比</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">较</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">，如果用</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">lpCmdLine</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">查</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">看命令行参数，没什</font>
														</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: SimSun; mso-bidi-font-family: SimSun; mso-fareast-language: ZH-CN">么</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">都没有。但是将</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">”-p”</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">改成</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">” -p”</span>
														<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">
																<font face="ＭＳ Ｐゴシック">，用可以看到参数是</font>
														</span>
														<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">-p</span>
														<font face="ＭＳ Ｐゴシック">
																<span lang="ZH-CN" style="FONT-SIZE: 10.5pt; COLOR: #111111; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-fareast-language: ZH-CN">，是不是很混乱？</span>
																<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #111111; FONT-FAMILY: Arial; mso-fareast-language: ZH-CN">
																		<o:p>
																		</o:p>
																</span>
														</font>
												</p>
										</div>
								</td>
						</tr>
				</tbody>
		</table>
<img src ="http://www.cppblog.com/ngaut/aggbug/14968.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-11-10 16:01 <a href="http://www.cppblog.com/ngaut/archive/2006/11/10/14968.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对HANDLE_MSG()的一点理解</title><link>http://www.cppblog.com/ngaut/archive/2006/10/24/14091.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 24 Oct 2006 07:33:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/10/24/14091.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/14091.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/10/24/14091.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/14091.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/14091.html</trackback:ping><description><![CDATA[
		<p>windowsx.h中有以下宏定义：<br /><br />  #define HANDLE_MSG(hwnd, message, fn)    \<br />  case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn))</p>
		<p>
				<br />  #define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) \<br />  ((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)<br /><br /><br />当我们写下下面的代码时：<br /> HANDLE_MSG(hWnd, WM_CREATE, pWindow-&gt;OnCreate);<br /><br />根据第一条宏定义会转化为：<br />case (WM_CREATE) : return HANDLE_WM_CREATE(((hwnd), (wParam), (lParam), (pWindow-&gt;OnCreate))<br /><br /><br />接下来使用第二条宏定义来替换，就成这样的了：<br />case (WM_CREATE) : return pWindow-&gt;OnCreate((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)<br /><br /><br /><br />忘了提醒了^_^，##的作用是将两个字符串连接起来</p>
<img src ="http://www.cppblog.com/ngaut/aggbug/14091.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-10-24 15:33 <a href="http://www.cppblog.com/ngaut/archive/2006/10/24/14091.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>对于recvfrom产生的错误10004的处理</title><link>http://www.cppblog.com/ngaut/archive/2006/10/08/13442.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sun, 08 Oct 2006 02:12:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/10/08/13442.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/13442.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/10/08/13442.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/13442.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/13442.html</trackback:ping><description><![CDATA[如果以阻塞的方式使用UDP，几乎肯定要在一个线程中recvfrom，此时有可能出现错误10004，一个可能的原因是主线程先结束了。<br /><br />下面是从网上找到的一点注释：<br /><br /><p align="left"><strong>Answer/Solution:</strong><font size="2"></font>A blocking operation was interrupted by a call to WSACancelBlockingCall. An asynchronous signal (such as SIGINT or SIGQUIT) was caught by the process during the execution of an interruptible function. If the signal handler performs a normal return, the interrupted function call will seem to have returned the error condition. </p><p align="left"><i>Developer suggestions:</i> You need to be prepared to handle this error on any functions that reference blocking sockets, or any calls to blocking functions, if you allow the user to cancel a blocking call. Whether to handle it as a fatal error or non-fatal error depends on the application and the context, so it's up to you to decide. </p><img src ="http://www.cppblog.com/ngaut/aggbug/13442.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-10-08 10:12 <a href="http://www.cppblog.com/ngaut/archive/2006/10/08/13442.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于NMAKE Fatal Error U1082 错误的问题</title><link>http://www.cppblog.com/ngaut/archive/2006/09/19/12728.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Tue, 19 Sep 2006 15:51:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/09/19/12728.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/12728.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/09/19/12728.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/12728.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/12728.html</trackback:ping><description><![CDATA[偶今日用makefile编译几个文件时，提示有NMAKE Fatal Error U1082  错误，'command' : cannot execute command; out of memory<br /><br />暂时还没有良好的解决方案，临时的办法：去掉 batch file(MSDN中看到的)，出现该错误的原因可能是link的obj太多，暂时还不肯定，明天继续，最近被移植问题弄得晕头转向^_^<img src ="http://www.cppblog.com/ngaut/aggbug/12728.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-09-19 23:51 <a href="http://www.cppblog.com/ngaut/archive/2006/09/19/12728.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于vc中struct字节对齐的问题</title><link>http://www.cppblog.com/ngaut/archive/2006/09/14/12475.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Thu, 14 Sep 2006 11:16:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/09/14/12475.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/12475.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/09/14/12475.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/12475.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/12475.html</trackback:ping><description><![CDATA[最近做的一个东东要移植到其它平台，一个发送端和一个接收端允许在不同的平台，编译器自然也不一样，所以struct对齐直接影响程序的正确允许。<br /><br />默认vc的struct是8byte对齐：<br />如果有这样的代码<br /><br />struct A<br /><br />{<br />   something...<br />}<br /><br />struct b<br /><br />{<br /><br /> A  a;   <br /><br />      //因为对齐的原因，这里可能有空隙<br />something...<br /><br />}<br /><br />然后将struct b转化为char*的时候就出现问题了，解决的办法设置为1BYTE对齐<img src ="http://www.cppblog.com/ngaut/aggbug/12475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-09-14 19:16 <a href="http://www.cppblog.com/ngaut/archive/2006/09/14/12475.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>无意中发现Geek Os中memcmp函数的bug</title><link>http://www.cppblog.com/ngaut/archive/2006/09/08/12155.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 08 Sep 2006 03:19:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/09/08/12155.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/12155.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/09/08/12155.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/12155.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/12155.html</trackback:ping><description><![CDATA[
		<p>具体位置：geekos-0.3.0\src\project6\src\common\string.c<br /><br />版本是geekos-0.3.0，不知道该BUG是不是故意留下来的^_^<br /><br />原来的函数如下：<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">
				<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> memcmp(</span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s1_, </span>
				<span style="COLOR: #0000ff">const</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">s2_, size_t n)<br /><img id="Codehighlighter1_55_254_Open_Image" onclick="this.style.display='none'; Codehighlighter1_55_254_Open_Text.style.display='none'; Codehighlighter1_55_254_Closed_Image.style.display='inline'; Codehighlighter1_55_254_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_55_254_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_55_254_Closed_Text.style.display='none'; Codehighlighter1_55_254_Open_Image.style.display='inline'; Codehighlighter1_55_254_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span>
				<span id="Codehighlighter1_55_254_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.cppblog.com/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_55_254_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">const</span>
						<span style="COLOR: #000000"> signed </span>
						<span style="COLOR: #0000ff">char</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">s1 </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> s1_, </span>
						<span style="COLOR: #000000">*</span>
						<span style="COLOR: #000000">s2 </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> s2_;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img id="Codehighlighter1_120_237_Open_Image" onclick="this.style.display='none'; Codehighlighter1_120_237_Open_Text.style.display='none'; Codehighlighter1_120_237_Closed_Image.style.display='inline'; Codehighlighter1_120_237_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_120_237_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_120_237_Closed_Text.style.display='none'; Codehighlighter1_120_237_Open_Image.style.display='inline'; Codehighlighter1_120_237_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">while</span>
						<span style="COLOR: #000000"> (n </span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">) </span>
						<span id="Codehighlighter1_120_237_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.cppblog.com/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_120_237_Open_Text">
								<span style="COLOR: #000000">{         </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">注意这里，n的值没有改变</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">     </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> cmp </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">s1 </span>
								<span style="COLOR: #000000">-</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">s2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000"> (cmp </span>
								<span style="COLOR: #000000">!=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />         </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> cmp;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     </span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">s1;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />     </span>
								<span style="COLOR: #000000">++</span>
								<span style="COLOR: #000000">s2;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />
								<br />
								<img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />
				</span>
		</div>
		<br />
		<br />修正的方法很简单：<br /><br />while (n-- &gt; 0) {   //处理n的值就OK了<img src ="http://www.cppblog.com/ngaut/aggbug/12155.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-09-08 11:19 <a href="http://www.cppblog.com/ngaut/archive/2006/09/08/12155.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个微秒级的延时函数</title><link>http://www.cppblog.com/ngaut/archive/2006/09/02/11953.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Sat, 02 Sep 2006 04:15:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/09/02/11953.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/11953.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/09/02/11953.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/11953.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/11953.html</trackback:ping><description><![CDATA[今天要用到一个微秒级的定时函数，到网上search下，找了几个都不能用，我晕，无奈，还是自己动手比较好，赶紧贴出来。<br /><br />免得以后要用的时候又不知道那里去找，方便自己也方便大家^_^    又避免重复发明轮子^_^<br /><br /><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"><img id="Codehighlighter1_0_214_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_214_Open_Text.style.display='none'; Codehighlighter1_0_214_Closed_Image.style.display='inline'; Codehighlighter1_0_214_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_0_214_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_214_Closed_Text.style.display='none'; Codehighlighter1_0_214_Open_Image.style.display='inline'; Codehighlighter1_0_214_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span id="Codehighlighter1_0_214_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id="Codehighlighter1_0_214_Open_Text"><span style="COLOR: #008000">/*</span><span style="COLOR: #008000">*******************************************************************<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Created:    2006/09/02<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    FileName:   t.c<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Author:        Liu Qi<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Purpose:    测试微秒级延时<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />********************************************************************</span><span style="COLOR: #008000">*/</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">windows.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">time.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />ULONG GetTimeDis(</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> tm first, </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> tm second)    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">计算两次时间差</span><span style="COLOR: #008000"><br /><img id="Codehighlighter1_340_479_Open_Image" onclick="this.style.display='none'; Codehighlighter1_340_479_Open_Text.style.display='none'; Codehighlighter1_340_479_Closed_Image.style.display='inline'; Codehighlighter1_340_479_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_340_479_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_340_479_Closed_Text.style.display='none'; Codehighlighter1_340_479_Open_Image.style.display='inline'; Codehighlighter1_340_479_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_340_479_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_340_479_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> abs((first.tm_hour </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3600</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> first.tm_min </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">60</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> first.tm_sec)<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> (second.tm_hour </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3600</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> second.tm_min </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">60</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> second.tm_sec));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> Delay(ULONG ulMicroSeconds)<br /><img id="Codehighlighter1_515_924_Open_Image" onclick="this.style.display='none'; Codehighlighter1_515_924_Open_Text.style.display='none'; Codehighlighter1_515_924_Closed_Image.style.display='inline'; Codehighlighter1_515_924_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_515_924_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_515_924_Closed_Text.style.display='none'; Codehighlighter1_515_924_Open_Image.style.display='inline'; Codehighlighter1_515_924_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_515_924_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_515_924_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    LARGE_INTEGER  timeStop; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    LARGE_INTEGER  timeStart; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    LARGE_INTEGER  Freq; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    ULONG  ulTimeToWait;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">QueryPerformanceFrequency( </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">Freq ))<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    ulTimeToWait </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> Freq.QuadPart </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> ulMicroSeconds </span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000">; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    QueryPerformanceCounter ( </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">timeStart ); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    timeStop </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> timeStart; <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">( timeStop.QuadPart </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> timeStart.QuadPart </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> ulTimeToWait ) <br /><img id="Codehighlighter1_877_922_Open_Image" onclick="this.style.display='none'; Codehighlighter1_877_922_Open_Text.style.display='none'; Codehighlighter1_877_922_Closed_Image.style.display='inline'; Codehighlighter1_877_922_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_877_922_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_877_922_Closed_Text.style.display='none'; Codehighlighter1_877_922_Open_Image.style.display='inline'; Codehighlighter1_877_922_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_877_922_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_877_922_Open_Text"><span style="COLOR: #000000">{ <br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        QueryPerformanceCounter( </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">timeStop ); <br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_944_1129_Open_Image" onclick="this.style.display='none'; Codehighlighter1_944_1129_Open_Text.style.display='none'; Codehighlighter1_944_1129_Closed_Image.style.display='inline'; Codehighlighter1_944_1129_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_944_1129_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_944_1129_Closed_Text.style.display='none'; Codehighlighter1_944_1129_Open_Image.style.display='inline'; Codehighlighter1_944_1129_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_944_1129_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_944_1129_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> tm timeStart, timeEnd;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    _getsystime(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">timeStart);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    Delay(</span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">);    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">3秒    </span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    _getsystime(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">timeEnd);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">用时：%d秒\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">, GetTimeDis(timeStart, timeEnd));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div><!-- SiteSearch Google --><form method="get" action="http://www.google.cn/custom" target="_top"><table border="0" bgcolor="#ffffff"><tr><td nowrap="nowrap" valign="top" align="left" height="32"><a href="http://www.google.com/"><img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle" /></a></td><td nowrap="nowrap"><input type="hidden" name="domains" value="www.csdn.net;www.cppblog.com;www.vckbase.com" /><label for="sbi" style="display: none">输入您的搜索字词</label><input type="text" name="q" size="31" maxlength="255" value="" id="sbi" /><label for="sbb" style="display: none">提交搜索表单</label><input type="submit" name="sa" value="搜索" id="sbb" /></td></tr><tr><td> </td><td nowrap="nowrap"><table><tr><td><input type="radio" name="sitesearch" value="" checked="" id="ss0" /><label for="ss0" title="搜索网络"><font size="-1" color="#000000">Web</font></label></td><td><input type="radio" name="sitesearch" value="www.csdn.net" id="ss1" /><label for="ss1" title="搜索 www.csdn.net"><font size="-1" color="#000000">www.csdn.net</font></label></td></tr><tr><td><input type="radio" name="sitesearch" value="www.cppblog.com" id="ss2" /><label for="ss2" title="搜索 www.cppblog.com"><font size="-1" color="#000000">www.cppblog.com</font></label></td><td><input type="radio" name="sitesearch" value="www.vckbase.com" id="ss3" /><label for="ss3" title="搜索 www.vckbase.com"><font size="-1" color="#000000">www.vckbase.com</font></label></td></tr></table><input type="hidden" name="client" value="pub-8303552920498244" /><input type="hidden" name="forid" value="1" /><input type="hidden" name="ie" value="GB2312" /><input type="hidden" name="oe" value="GB2312" /><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1" /><input type="hidden" name="hl" value="zh-CN" /></td></tr></table></form><!-- SiteSearch Google --><img src ="http://www.cppblog.com/ngaut/aggbug/11953.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-09-02 12:15 <a href="http://www.cppblog.com/ngaut/archive/2006/09/02/11953.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>字符数组处理要谨慎啊</title><link>http://www.cppblog.com/ngaut/archive/2006/08/24/11662.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Thu, 24 Aug 2006 11:16:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/08/24/11662.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/11662.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/08/24/11662.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/11662.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/11662.html</trackback:ping><description><![CDATA[偶用strncmp比较两个MAC地址时出错了，原来MAC地址的开始是0 ，于是变成了空串，看来还是memcmp好啊，不容易出错^_^<br />MAC地址是这样定义的：<br /><br />UCHAR Mac[6]; <br /><br /><br /><br />汗!<br /><img src ="http://www.cppblog.com/ngaut/aggbug/11662.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-08-24 19:16 <a href="http://www.cppblog.com/ngaut/archive/2006/08/24/11662.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>失之毫厘，差之千里啊</title><link>http://www.cppblog.com/ngaut/archive/2006/08/21/11532.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Mon, 21 Aug 2006 08:45:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/08/21/11532.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/11532.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/08/21/11532.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/11532.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/11532.html</trackback:ping><description><![CDATA[因为自己一不小心，在头文件里的一个函数声明时露了一个分号，造成：<br />
error C2085: 'NCCancelLogin' : not in formal parameter list和一大堆的乱七八糟的错误信息。<br />
而且错误信息距离事发之地太远。花了偶三个多小时来查找错误，汗.......<br />
贴在这里，免得以后忘记了。<br /><img src ="http://www.cppblog.com/ngaut/aggbug/11532.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-08-21 16:45 <a href="http://www.cppblog.com/ngaut/archive/2006/08/21/11532.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实习第11天，复习堆排序，顺便写了个DEMO</title><link>http://www.cppblog.com/ngaut/archive/2006/07/12/9731.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Wed, 12 Jul 2006 04:18:00 GMT</pubDate><guid>http://www.cppblog.com/ngaut/archive/2006/07/12/9731.html</guid><wfw:comment>http://www.cppblog.com/ngaut/comments/9731.html</wfw:comment><comments>http://www.cppblog.com/ngaut/archive/2006/07/12/9731.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/ngaut/comments/commentRss/9731.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ngaut/services/trackbacks/9731.html</trackback:ping><description><![CDATA[写得还算认真，本来觉得自己已经懂了，动手的时候才知道细节上好多不清楚。看来以后要多动手了，汗<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"><img id="Codehighlighter1_0_118_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_118_Open_Text.style.display='none'; Codehighlighter1_0_118_Closed_Image.style.display='inline'; Codehighlighter1_0_118_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_0_118_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_118_Closed_Text.style.display='none'; Codehighlighter1_0_118_Open_Image.style.display='inline'; Codehighlighter1_0_118_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span id="Codehighlighter1_0_118_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</span><span id="Codehighlighter1_0_118_Open_Text"><span style="COLOR: #008000">/*</span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />*   FILE:           heap.c<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />*   DATA:           2006.7.11<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />*   AUTHOR:         Liu Qi<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />*   DESCRIPTION:    heap demo<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /></span><span style="COLOR: #008000">*/</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">../common/config.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">heap.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> LeftChild(r) ((r) * 2 + 1)</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> heapify(ElemType arr[], </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> heapSize, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> root)<br /><img id="Codehighlighter1_262_668_Open_Image" onclick="this.style.display='none'; Codehighlighter1_262_668_Open_Text.style.display='none'; Codehighlighter1_262_668_Closed_Image.style.display='inline'; Codehighlighter1_262_668_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_262_668_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_262_668_Closed_Text.style.display='none'; Codehighlighter1_262_668_Open_Image.style.display='inline'; Codehighlighter1_262_668_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_262_668_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_262_668_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000"> ( </span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">isLeaf(root, heapSize))    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">非叶节点,必有左孩子</span><span style="COLOR: #008000"><br /><img id="Codehighlighter1_321_666_Open_Image" onclick="this.style.display='none'; Codehighlighter1_321_666_Open_Text.style.display='none'; Codehighlighter1_321_666_Closed_Image.style.display='inline'; Codehighlighter1_321_666_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_321_666_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_321_666_Closed_Text.style.display='none'; Codehighlighter1_321_666_Open_Image.style.display='inline'; Codehighlighter1_321_666_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="COLOR: #000000">    </span><span id="Codehighlighter1_321_666_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_321_666_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> maxChild </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> LeftChild(root);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">有右孩子，并且右孩子大于左孩子</span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> ( maxChild </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> heapSize </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&amp;&amp;</span><span style="COLOR: #000000"> arr[maxChild] </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> arr[maxChild </span><span style="COLOR: #000000">+</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">])<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />                maxChild</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">取右孩子<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">没有右孩子</span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">        </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> ( arr[root] </span><span style="COLOR: #000000">&gt;=</span><span style="COLOR: #000000"> arr[maxChild] )   </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">根比孩子大，不用调整</span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="COLOR: #000000">            </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        swap( </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">arr[root], </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">arr[maxChild] );<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        root </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> maxChild;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> MakeHeap(ElemType arr[], </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> len)<br /><img id="Codehighlighter1_710_848_Open_Image" onclick="this.style.display='none'; Codehighlighter1_710_848_Open_Text.style.display='none'; Codehighlighter1_710_848_Closed_Image.style.display='inline'; Codehighlighter1_710_848_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_710_848_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_710_848_Closed_Text.style.display='none'; Codehighlighter1_710_848_Open_Image.style.display='inline'; Codehighlighter1_710_848_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_710_848_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_710_848_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">/</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">; </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">last node's root</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</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 /><img id="Codehighlighter1_810_846_Open_Image" onclick="this.style.display='none'; Codehighlighter1_810_846_Open_Text.style.display='none'; Codehighlighter1_810_846_Closed_Image.style.display='inline'; Codehighlighter1_810_846_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_810_846_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_810_846_Closed_Text.style.display='none'; Codehighlighter1_810_846_Open_Image.style.display='inline'; Codehighlighter1_810_846_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_810_846_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_810_846_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        heapify(arr, len, i);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> SortHeap(ElemType arr[], </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> len)<br /><img id="Codehighlighter1_889_1017_Open_Image" onclick="this.style.display='none'; Codehighlighter1_889_1017_Open_Text.style.display='none'; Codehighlighter1_889_1017_Closed_Image.style.display='inline'; Codehighlighter1_889_1017_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_889_1017_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_889_1017_Closed_Text.style.display='none'; Codehighlighter1_889_1017_Open_Image.style.display='inline'; Codehighlighter1_889_1017_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_889_1017_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_889_1017_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> i </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</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 /><img id="Codehighlighter1_941_1015_Open_Image" onclick="this.style.display='none'; Codehighlighter1_941_1015_Open_Text.style.display='none'; Codehighlighter1_941_1015_Closed_Image.style.display='inline'; Codehighlighter1_941_1015_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_941_1015_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_941_1015_Closed_Text.style.display='none'; Codehighlighter1_941_1015_Open_Image.style.display='inline'; Codehighlighter1_941_1015_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_941_1015_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_941_1015_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        swap(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">arr[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">], </span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">arr[i]);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        heapify(arr, i, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">); </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">调整堆属性</span><span style="COLOR: #008000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" /></span><span style="COLOR: #000000">    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" />BOOL isLeaf(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> root, </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> len)<br /><img id="Codehighlighter1_1051_1107_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1051_1107_Open_Text.style.display='none'; Codehighlighter1_1051_1107_Closed_Image.style.display='inline'; Codehighlighter1_1051_1107_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1051_1107_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1051_1107_Closed_Text.style.display='none'; Codehighlighter1_1051_1107_Open_Image.style.display='inline'; Codehighlighter1_1051_1107_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_1051_1107_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_1051_1107_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> LeftChild(root) </span><span style="COLOR: #000000">&lt;=</span><span style="COLOR: #000000"> len </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">?</span><span style="COLOR: #000000"> FALSE : TRUE;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><br /><br />偶比较懒，想了一会，弄了一个自动化测试的代码：<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"><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">heap.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> SIZE 5</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">#define</span><span style="COLOR: #000000"> TEST_TIMES 100</span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main(</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_73_418_Open_Image" onclick="this.style.display='none'; Codehighlighter1_73_418_Open_Text.style.display='none'; Codehighlighter1_73_418_Closed_Image.style.display='inline'; Codehighlighter1_73_418_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_73_418_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_73_418_Closed_Text.style.display='none'; Codehighlighter1_73_418_Open_Image.style.display='inline'; Codehighlighter1_73_418_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span id="Codehighlighter1_73_418_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_73_418_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </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">0</span><span style="COLOR: #000000">;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    ElemType arr[SIZE];<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> ( ; i </span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000"> TEST_TIMES; i</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br /><img id="Codehighlighter1_152_390_Open_Image" onclick="this.style.display='none'; Codehighlighter1_152_390_Open_Text.style.display='none'; Codehighlighter1_152_390_Closed_Image.style.display='inline'; Codehighlighter1_152_390_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_152_390_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_152_390_Closed_Text.style.display='none'; Codehighlighter1_152_390_Open_Image.style.display='inline'; Codehighlighter1_152_390_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_152_390_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/images/dot.gif" /></span><span id="Codehighlighter1_152_390_Open_Text"><span style="COLOR: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        RandArray(arr, ARRAY_LENGTH(arr), </span><span style="COLOR: #000000">20</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        MakeHeap(arr, ARRAY_LENGTH(arr));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        SortHeap(arr, ARRAY_LENGTH(arr));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        check_ascending(arr, ARRAY_LENGTH(arr));<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />        PrintArray(arr, ARRAY_LENGTH(arr), </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%d </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> EXIT_SUCCESS;<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="COLOR: #000000"><br /><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top" /></span></div><br /><img src ="http://www.cppblog.com/ngaut/aggbug/9731.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ngaut/" target="_blank">ngaut</a> 2006-07-12 12:18 <a href="http://www.cppblog.com/ngaut/archive/2006/07/12/9731.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>