﻿<?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++博客-xosen</title><link>http://www.cppblog.com/xosen/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 09 Apr 2026 03:20:09 GMT</lastBuildDate><pubDate>Thu, 09 Apr 2026 03:20:09 GMT</pubDate><ttl>60</ttl><item><title>The Theory of Stencil Shadow Volumes</title><link>http://www.cppblog.com/xosen/archive/2009/12/20/103571.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Sun, 20 Dec 2009 10:23:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/12/20/103571.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/103571.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/12/20/103571.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/103571.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/103571.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: The Theory of Stencil Shadow Volumes&nbsp;GameDev.netThe Theory of Stencil Shadow Volumes&nbsp;by&nbsp;Hun Yen KwoonIntroductionShadows used to be just a patch of darkened texture, usually round in sh...&nbsp;&nbsp;<a href='http://www.cppblog.com/xosen/archive/2009/12/20/103571.html'>阅读全文</a><img src ="http://www.cppblog.com/xosen/aggbug/103571.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-12-20 18:23 <a href="http://www.cppblog.com/xosen/archive/2009/12/20/103571.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>10个经典的字符串hash函数的C代码实现</title><link>http://www.cppblog.com/xosen/archive/2009/10/21/99089.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Wed, 21 Oct 2009 02:25:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/10/21/99089.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/99089.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/10/21/99089.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/99089.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/99089.html</trackback:ping><description><![CDATA[<p>unsigned int RSHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int b&nbsp;&nbsp;&nbsp; = 378551;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int a&nbsp;&nbsp;&nbsp; = 63689;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = hash * a + (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&nbsp;&nbsp;&nbsp; = a * b;&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of RS Hash Function */&nbsp; <br>&nbsp; <br>unsigned int JSHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 1315423911;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash ^= ((hash &lt;&lt; 5) + (*str) + (hash &gt;&gt; 2));&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of JS Hash Function */&nbsp; <br>&nbsp; <br>unsigned int PJWHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; const unsigned int BitsInUnsignedInt = (unsigned int)(sizeof(unsigned int) * 8);&nbsp;&nbsp; <br>&nbsp;&nbsp; const unsigned int ThreeQuarters&nbsp;&nbsp;&nbsp;&nbsp; = (unsigned int)((BitsInUnsignedInt&nbsp; * 3) / 4);&nbsp;&nbsp; <br>&nbsp;&nbsp; const unsigned int OneEighth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = (unsigned int)(BitsInUnsignedInt / 8);&nbsp;&nbsp; <br>&nbsp;&nbsp; const unsigned int HighBits&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = (unsigned int)(0xFFFFFFFF) &lt;&lt; (BitsInUnsignedInt - OneEighth);&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (hash &lt;&lt; OneEighth) + (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((test = hash &amp; HighBits)&nbsp; != 0)&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (( hash ^ (test &gt;&gt; ThreeQuarters)) &amp; (~HighBits));&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of&nbsp; P. J. Weinberger Hash Function */&nbsp; <br>&nbsp; <br>unsigned int ELFHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int x&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (hash &lt;&lt; 4) + (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((x = hash &amp; 0xF0000000L) != 0)&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash ^= (x &gt;&gt; 24);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash &amp;= ~x;&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of ELF Hash Function */&nbsp; <br>&nbsp; <br>unsigned int BKDRHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int seed = 131; /* 31 131 1313 13131 131313 etc.. */&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (hash * seed) + (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of BKDR Hash Function */&nbsp; <br>&nbsp; <br>unsigned int SDBMHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = (*str) + (hash &lt;&lt; 6) + (hash &lt;&lt; 16) - hash;&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of SDBM Hash Function */&nbsp; <br>&nbsp; <br>unsigned int DJBHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 5381;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = ((hash &lt;&lt; 5) + hash) + (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of DJB Hash Function */&nbsp; <br>&nbsp; <br>unsigned int DEKHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = len;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = ((hash &lt;&lt; 5) ^ (hash &gt;&gt; 27)) ^ (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of DEK Hash Function */&nbsp; <br>&nbsp; <br>unsigned int BPHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash = hash &lt;&lt; 7 ^ (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of BP Hash Function */&nbsp; <br>&nbsp; <br>unsigned int FNVHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; const unsigned int fnv_prime = 0x811C9DC5;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash *= fnv_prime;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash ^= (*str);&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of FNV Hash Function */&nbsp; <br>&nbsp; <br>unsigned int APHash(char* str, unsigned int len)&nbsp;&nbsp; <br>{&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int hash = 0xAAAAAAAA;&nbsp;&nbsp; <br>&nbsp;&nbsp; unsigned int i&nbsp;&nbsp;&nbsp; = 0;&nbsp;&nbsp; <br>&nbsp;&nbsp; for(i = 0; i &lt; len; str++, i++)&nbsp;&nbsp; <br>&nbsp;&nbsp; {&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash ^= ((i &amp; 1) == 0) ? (&nbsp; (hash &lt;&lt;&nbsp; 7) ^ (*str) * (hash &gt;&gt; 3)) :&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (~((hash &lt;&lt; 11) + (*str) ^ (hash &gt;&gt; 5)));&nbsp;&nbsp; <br>&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp; return hash;&nbsp;&nbsp; <br>}&nbsp;&nbsp; <br>/* End Of AP Hash Function */&nbsp; </p>
<p><br><font color=#002c99>更多参考: <a href="http://www.partow.net/programming/hashfunctions/">http://www.partow.net/programming/hashfunctions/</a></font></p>
<img src ="http://www.cppblog.com/xosen/aggbug/99089.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-10-21 10:25 <a href="http://www.cppblog.com/xosen/archive/2009/10/21/99089.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于Debug时的R6034的错误</title><link>http://www.cppblog.com/xosen/archive/2009/09/11/95956.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Fri, 11 Sep 2009 12:22:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/09/11/95956.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/95956.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/09/11/95956.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/95956.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/95956.html</trackback:ping><description><![CDATA[如果使用了VS2005及以上的编译器，则在debug时可能会出现该错误<br><br>出现这个问题，你需要检查下 项目属性-&gt;Configuration Properties-&gt;Linker-&gt;Manifest File下<br><br>Generate: YES<br>Manifest File: 要设置到正确路径
<img src ="http://www.cppblog.com/xosen/aggbug/95956.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-09-11 20:22 <a href="http://www.cppblog.com/xosen/archive/2009/09/11/95956.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC++编译选项详解</title><link>http://www.cppblog.com/xosen/archive/2009/05/10/82462.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Sun, 10 May 2009 04:40:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/05/10/82462.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/82462.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/05/10/82462.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/82462.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/82462.html</trackback:ping><description><![CDATA[<div class=tit>VC++编译选项详解</div>
<div class=date>2009-03-16 20:51</div>
<table style="TABLE-LAYOUT: fixed">
    <tbody>
        <tr>
            <td>
            <div class=cnt id=blog_text>
            <p>优化-<br>[]==================================================================================[]</p>
            <p>/O1 最小化空间 minimize space <br>/Op[-] 改善浮点数一致性 improve floating-pt consistency <br>/O2 最大化速度 maximize speed <br>/Os 优选代码空间 favor code space <br>/Oa 假设没有别名 assume no aliasing <br>/Ot 优选代码速度 favor code speed <br>/Ob 内联展开（默认 n=0） inline expansion (default n=0) <br>/Ow 假设交叉函数别名 assume cross-function aliasing <br>/Od 禁用优化（默认值） disable optimizations (default) <br>/Ox 最大化选项。(/Ogityb2 /Gs) maximum opts. (/Ogityb1 /Gs) <br>/Og 启用全局优化 enable global optimization <br>/Oy[-] 启用框架指针省略 enable frame pointer omission <br>/Oi 启用内建函数 enable intrinsic functions</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -代码生成-<br>[]==================================================================================[]</p>
            <p>/G3 为 80386 进行优化 optimize for 80386 <br>/G4 为 80486 进行优化 optimize for 80486 <br>/GR[-] 启用 C++ RTTI enable C++ RTTI <br>/G5 为 Pentium 进行优化 optimize for Pentium <br>/G6 为 Pentium Pro 进行优化 optimize for Pentium Pro <br>/GX[-] 启用 C++ 异常处理（与 /EHsc 相同） enable C++ EH (same as /EHsc) <br>/EHs 启用同步 C++ 异常处理 enable synchronous C++ EH <br>/GD 为 Windows DLL 进行优化 optimize for Windows DLL <br>/GB 为混合模型进行优化（默认） optimize for blended model (default) <br>/EHa 启用异步 C++ 异常处理 enable asynchronous C++ EH <br>/Gd __cdecl 调用约定 __cdecl calling convention <br>/EHc extern&#8220;C&#8221;默认为 nothrow extern "C" defaults to nothrow <br>/Gr __fastcall 调用约定 __fastcall calling convention <br>/Gi[-] 启用增量编译 enable incremental compilation <br>/Gz __stdcall 调用约定 __stdcall calling convention <br>/Gm[-] 启用最小重新生成 enable minimal rebuild <br>/GA 为 Windows 应用程序进行优化 optimize for Windows Application <br>/Gf 启用字符串池 enable string pooling <br>/QIfdiv[-] 启用 Pentium FDIV 修复 enable Pentium FDIV fix <br>/GF 启用只读字符串池 enable read-only string pooling <br>/QI0f[-] 启用 Pentium 0x0f 修复 enable Pentium 0x0f fix <br>/Gy 分隔链接器函数 separate functions for linker <br>/GZ 启用运行时调试检查 enable runtime debug checks <br>/Gh 启用钩子函数调用 enable hook function call <br>/Ge 对所有函数强制堆栈检查 force stack checking for all funcs <br>/Gs[num] 禁用堆栈检查调用 disable stack checking calls</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp; -输出文件-<br>[]==================================================================================[]</p>
            <p>/Fa[file] 命名程序集列表文件 name assembly listing file <br>/Fo 命名对象文件 name object file <br>/FA[sc] 配置程序集列表 configure assembly listing <br>/Fp 命名预编译头文件 name precompiled header file <br>/Fd[file] 命名 .PDB 文件 name .PDB file <br>/Fr[file] 命名源浏览器文件 name source browser file <br>/Fe 命名可执行文件 name executable file <br>/FR[file] 命名扩展 .SBR 文件 name extended .SBR file <br>/Fm[file] 命名映射文件 name map file</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp; -预处理器-<br>[]==================================================================================[]</p>
            <p>/FI 命名强制包含文件 name forced include file <br>/C 不吸取注释 don't strip comments <br>/U 移除预定义宏 remove predefined macro <br>/D{=|#} 定义宏 define macro <br>/u 移除所有预定义宏 remove all predefined macros <br>/E 将预处理定向到标准输出 preprocess to stdout <br>/I 添加到包含文件的搜索路径 add to include search path <br>/EP 将预处理定向到标准输出，不要带行号 preprocess to stdout, no #line <br>/X 忽略&#8220;标准位置&#8221; ignore "standard places" <br>/P 预处理到文件 preprocess to file</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp; -语言-<br>[]==================================================================================[]</p>
            <p>/Zi 启用调试信息 enable debugging information <br>/Zl 忽略 .OBJ 中的默认库名 omit default library name in .OBJ <br>/ZI 启用调试信息的&#8220;编辑并继续&#8221;功能 enable Edit and Continue debug info <br>/Zg 生成函数原型 generate function prototypes <br>/Z7 启用旧式调试信息 enable old-style debug info <br>/Zs 只进行语法检查 syntax check only <br>/Zd 仅要行号调试信息 line number debugging info only <br>/vd{0|1} 禁用/启用 vtordisp disable/enable vtordisp <br>/Zp[n] 在 n 字节边界上包装结构 pack structs on n-byte boundary <br>/vm 指向成员的指针类型 type of pointers to members <br>/Za 禁用扩展（暗指 /Op） disable extensions (implies /Op) <br>/noBool 禁用&#8220;bool&#8221;关键字 disable "bool" keyword <br>/Ze 启用扩展（默认） enable extensions (default)</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp; - 杂项 -<br>[]==================================================================================[]</p>
            <p>/?, /help 打印此帮助消息 print this help message <br>/c 只编译，不链接 compile only, no link <br>/W 设置警告等级（默认 n=1） set warning level (default n=1) <br>/H 最大化外部名称长度 max external name length <br>/J 默认 char 类型是 unsigned default char type is unsigned <br>/nologo 取消显示版权消息 suppress copyright message <br>/WX 将警告视为错误 treat warnings as errors <br>/Tc 将文件编译为 .c compile file as .c <br>/Yc[file] 创建 .PCH 文件 create .PCH file <br>/Tp 将文件编译为 .cpp compile file as .cpp <br>/Yd 将调试信息放在每个 .OBJ 中 put debug info in every .OBJ <br>/TC 将所有文件编译为 .c compile all files as .c <br>/TP 将所有文件编译为 .cpp compile all files as .cpp <br>/Yu[file] 使用 .PCH 文件 use .PCH file <br>/V 设置版本字符串 set version string <br>/YX[file] 自动的 .PCH 文件 automatic .PCH <br>/w 禁用所有警告 disable all warnings <br>/Zm 最大内存分配（默认为 %） max memory alloc (% of default)</p>
            <p>[]==================================================================================[]<br>&nbsp;&nbsp;&nbsp;&nbsp; -链接-<br>[]==================================================================================[]</p>
            <p>/MD 与 MSVCRT.LIB 链接 link with MSVCRT.LIB <br>/MDd 与 MSVCRTD.LIB 调试库链接 link with MSVCRTD.LIB debug lib <br>/ML 与 LIBC.LIB 链接 link with LIBC.LIB <br>/MLd 与 LIBCD.LIB 调试库链接 link with LIBCD.LIB debug lib <br>/MT 与 LIBCMT.LIB 链接 link with LIBCMT.LIB <br>/MTd 与 LIBCMTD.LIB 调试库链接 link with LIBCMTD.LIB debug lib <br>/LD 创建 .DLL Create .DLL <br>/F 设置堆栈大小 set stack size <br>/LDd 创建 .DLL 调试库 Create .DLL debug libary <br>/link [链接器选项和库] [linker options and libraries]</p>
            <p><br>///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vc 编译连接选项<br>///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////</p>
            <p>　　大家可能一直在用VC开发软件，但是对于这个编译器却未必很了解。原因是多方面的。大多数情况下，我们只停留在&#8220;使用&#8221;它，而不会想去&#8220;了解&#8221;它。因为它只是一个工具，我们宁可把更多的精力放在C++语言和软件设计上。我们习惯于这样一种&#8220;模式&#8221;：建立一个项目，然后写代码，然后编译，反反复复调试。但是，所谓：&#8220;公欲善其事，必先利其器&#8221;。如果我们精于VC开发环境，我们是不是能够做得更加游刃有余呢？</p>
            <p>　　闲话少说。我们先来看一下VC的处理流程，大致分为两步：编译和连接。源文件通过编译生成了.obj文件；所有.obj文件和.lib文件通过连接生成.exe文件或.dll文件。下面，我们分别讨论这两个步骤的一些细节。</p>
            <p><br>　　编译参数的设置。主要通过VC的菜单项Project-&gt;Settings-&gt;C/C++页来完成。我们可以看到这一页的最下面Project Options中的内容，一般如下：</p>
            <p>/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_M<br>BCS" /Fp"Debug/WritingDlgTest.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c</p>
            <p>　　各个参数代表的意义，可以参考Msdn。比如/nologo表示编译时不在输出窗口显示这些设置（我们可以把这个参数去掉来看看效果）等等。一般我们不会直接修改这些设置，而是通过这一页最上面的Category中的各项来完成。</p>
            <p>　　1) General：一些总体设置。Warning level用来控制警告信息，其中Level 1是最严重的级别；Warnings as errors将警告信息当作错误处理；Optimizations是代码优化，可以在Category的Optimizations项中进行更细的设置；Generate browse info用以生成.sbr文件，记录类、变量等符号信息，可以在Category的Listing Files项中进行更多的设置。Debug info，生成调试信息：None，不产生任何调试信息（编译比较快）；Line Numbers Only，仅生成全局的和外部符号的调试信息到.OBJ文件或.EXE文件，减小目标文件的尺寸；C 7.0- Compatible，记录调试器用到的所有符号信息到.OBJ文件和.EXE文件；Program Database，创建.PDB文件记录所有调试信息；Program Database for "Edit &amp; Continue"，创建.PDB文件记录所有调试信息，并且支持调试时编辑。</p>
            <p>　　2) C++ Language：pointer_to_member representation用来设置类定义/引用的先后关系，一般为Best-Case Always表示在引用类之前该类肯定已经定义了；Enable Exception Handling，进行同步的异常处理；Enable Run-Time Type Information迫使编译器增加代码在运行时进行对象类型检查；Disable Construction Displacements，设置类构造/析构函数调用虚函数问题。</p>
            <p>　　3) Code Generation：Processor表示代码指令优化，可以为80386、80486、Pentium、Pentium Pro，或者Blend表示混合以上各种优化。Use run-time library用以指定程序运行时使用的运行时库（单线程或多线程，Debug版本或Release版本），有一个原则就是，一个进程不要同时使用几个版本的运行时库。Single-Threaded，静态连接LIBC.LIB库；Debug Single-Threaded，静态连接LIBCD.LIB库；Multithreaded，静态连接LIBCMT.LIB库；Debug Multithreaded，静态连接LIBCMTD.LIB库；Multithreaded DLL，动态连接MSVCRT.DLL库；Debug Multithreaded DLL，动态连接MSVCRTD.DLL库。连接了单线程库就不支持多线程调用，连接了多线程库就要求创建多线程的应用程序。</p>
            <p>　　Calling convention可以用来设定调用约定，有三种：__cdecl、__fastcall和__stdcall。各种调用约定的主要区别在于，函数调用时，函数的参数是从左到右压入堆栈还是从右到左压入堆栈；在函数返回时，由函数的调用者来清理压入堆栈的参数还是由函数本身来清理；以及在编译时对函数名进行的命名修饰（可以通过Listing Files看到各种命名修饰方式）。Struct member alignment用以指定数据结构中的成员变量在内存中是按几字节对齐的，根据计算机数据总线的位数，不同的对齐方式存取数据的速度不一样。这个参数对数据包网络传输等应用尤为重要，不是存取速度问题，而是数据位的精确定义问题，一般在程序中使用#pragma pack来指定。<br>　　4) Customize：Disable Language Extensions，表示不使用微软为标准C做的语言扩展；Eliminate Duplicate Strings，主要用于字符串优化（将字符串放到缓充池里以节省空间），使用这个参数，使得</p>
            <p><br>char *sBuffer = "This is a character buffer";</p>
            <p>char *tBuffer = "This is a character buffer";<br></p>
            <p><br>　　sBuffer和tBuffer指向的是同一块内存空间；Enable Function-Level Linking ，告诉编译器将各个函数按打包格式编译；Enables minimal rebuild，通过保存关联信息到.IDB文件，使编译器只对最新类定义改动过的源文件进行重编译，提高编译速度；Enable Incremental Compilation，同样通过.IDB文件保存的信息，只重编译最新改动过的函数；Suppress Startup Banner and Information Messages，用以控制参数是否在output窗口输出。</p>
            <p>　　5) Listing Files：Generate browse info的功能上面已经提到过。这里可以进行更多的设置。Exclude Local Variables from Browse Info表示是否将局部变量的信息放到.SBR文件中。Listing file type可以设置生成的列表信息文件的内容：Assembly-Only Listing仅生成汇编代码文件（.ASM扩展名）；Assembly With Machine Code生成机器代码和汇编代码文件（.COD扩展名）；Assembly With Source Code生成源代码和汇编代码文件（.ASM扩展名）；Assembly, Machine Code,and Source生成机器码、源代码和汇编代码文件（.COD扩展名）。Listing file name为生成的信息文件的路径，一般为Debug或Release目录下，生成的文件名自动取源文件的文件名。</p>
            <p>　　6) Optimizations：代码优化设置。可以选择Maximize Speed生成最快速的代码，或Minimize Size生成最小尺寸的程序，或者Customize定制优化。定制的内容包括：</p>
            <p>　　Assume No Aliasing，不使用别名（提高速度）；</p>
            <p>　　Assume Aliasing Across Function Calls，仅函数内部不使用别名；</p>
            <p>　　Global Optimizations，全局优化，比如经常用到的变量使用寄存器保存，或者循环内的计算优化，如</p>
            <p>i = -100;</p>
            <p>while( i &lt; 0 ){ i += x + y;}<br></p>
            <p><br>　　会被优化为</p>
            <p><br>i = -100;<br>t = x + y;<br>while( i &lt; 0 ){i += t;}<br>Generate Intrinsic Functions，使用内部函数替换一些函数调用（提高速度）； <br>Improve Float Consistency，浮点运算方面的优化；<br>Favor Small Code，程序（exe或dll）尺寸优化优先于代码速度优化；<br>Favor Fast Code，程序（exe或dll）代码速度优化优先于尺寸优化；<br>Frame-Pointer Omission，不使用帧指针，以提高函数调用速度；<br>Full Optimization，组合了几种参数，以生成最快的程序代码。<br></p>
            <p><br>　　Inline function expansion，内联函数扩展的三种优化（使用内联可以节省函数调用的开销，加快程序速度）：Disable不使用内联；Only __inline，仅函数定义前有inline或__inline标记使用内联；Any Suitable，除了inline或__inline标记的函数外，编译器&#8220;觉得&#8221;应该使用内联的函数，都使用内联。</p>
            <p>　　7) Precompiled Headers：预编译头文件的设置。使用预编译可以提高重复编译的速度。VC一般将一些公共的、不大变动的头文件（比如afxwin.h等）集中放到stdafx.h中，这一部分代码就不必每次都重新编译（除非是Rebuild All）。</p>
            <p>　　8) Preprocessor：预编译处理。可以定义/解除定义一些常量。Additional include directories，可以指定额外的包含目录，一般是相对于本项目的目录，如..\Include。</p>
            <p><br>　　连接参数的设置。主要通过VC的菜单项Project-&gt;Settings-&gt;Link页来完成。我们可以看到这一页的最下面Project Options中的内容，一般如下：</p>
            <p>/nologo /subsystem:windows /incremental:yes /pdb:"Debug/WritingDlgTest.pdb" /debug /machi<br>ne:I386 /out:"Debug/WritingDlgTest.exe" /pdbtype:sept</p>
            <p>　　下面我们分别来看一下Category中的各项设置。</p>
            <p>　　1) General：一些总体设置。可以设置生成的文件路径、文件名；连接的库文件；Generate debug info，生成Debug信息到.PDB文件（具体格式可以在Category-&gt;Debug中设置）；Ignore All Default Libraries，放弃所有默认的库连接；Link Incrementally，通过生成. ILK文件实现递增式连接以提高后续连接速度，但一般这种方式下生成的文件（EXE或DLL）较大；Generate Mapfile，生成.MAP文件记录模块相关信息；Enable Profiling，这个参数通常与Generate Mapfile参数同时使用，而且如果产生Debug信息的话，不能用.PDB文件，而且必须用Microsoft Format。</p>
            <p>　　2) Customize：这里可以进行使用程序数据库文件的设置。Force File Output ，强制产生输出文件（EXE或DLL）；Print Progress Messages，可以将连接过程中的进度信息输出到Output窗口。</p>
            <p>　　3) Debug：设置是否生成调试信息，以及调试信息的格式。格式可以有Microsoft Format、COFF Format（Common Object File Format）和Both Formats三种选择；Separate Types，表示将Debug格式信息以独立的.PDB文件存放，还是直接放在各个源文件的.PDB文件中。选中的话，表示采用后者的方式，这种方式调试启动比较快。</p>
            <p>　　4) Input：这里可以指定要连接的库文件，放弃连接的库文件。还可以增加额外的库文件目录，一般是相对于本项目的目录，如..\Lib。Force Symbol References，可以指定连接特定符号定义的库。</p>
            <p>　　5) Output：Base Address可以改变程序默认的基地址（EXE文件默认为0x400000，DLL默认为x10000000），操作系统装载一个程序时总是试着先从这个基地址开始。Entry-Point Symbol可以指定程序的入口地址，一般为一个函数名（且必须采用__stdcall调用约定）。一般Win32的程序，EXE的入口为WinMain，DLL的入口为DllEntryPoint；最好让连接器自动设置程序的入口点。默认情况下，通过一个C的运行时库函数来实现：控制台程序采用mainCRTStartup (或wmainCRTStartup)去调用程序的main (或wmain)函数；Windows程序采用WinMainCRTStartup (或 wWinMainCRTStartup)调用程序的WinMain (或 wWinMain，必须采用__stdcall调用约定)；DLL采用_DllMainCRTStartup调用DllMain函数（必须采用__stdcall调用约定）。Stack allocations，用以设置程序使用的堆栈大小（请使用十进制），默认为1兆字节。Version Information告诉连接器在EXE或DLL文件的开始部分放上版本号。</p>
            <p><br>　　值得注意的是，上面各个参数是大小写敏感的；在参数后加上&#8220;-&#8221;表示该参数无效；各个参数值选项<br>有&#8220;*&#8221;的表示为该参数的默认值；可以使用页右上角的&#8220;Reset&#8221;按钮来恢复该页的所有默认设置。</p>
            <p><br>　　其它一些参数设置</p>
            <p>　　1) Project-&gt;Settings-&gt;General，可以设置连接MFC库的方式（静态或动态）。如果是动态连<br>接，在你的软件发布时不要忘了带上MFC的DLL。</p>
            <p>　　2) Project-&gt;Settings-&gt;Debug，可以设置调试时运行的可执行文件，以及命令行参数等。</p>
            <p>　　3) Project-&gt;Settings-&gt;Custom Build，可以设置编译/连接成功后自动执行一些操作。比较有<br>用的是，写COM时希望VC对编译通过的COM文件自动注册，可以如下设置：</p>
            <p>　　　Description: Register COM</p>
            <p>　　　Commands: regsvr32 /s /c $(TargetPath)</p>
            <p>　　　echo regsvr32 exe.time &gt; $(TargetDir)\$(TargetName).trg</p>
            <p>　　　Outputs: $(TargetDir)\$(TargetName).trg</p>
            <p>　　4) Tools-&gt;Options-&gt;Directories，设置系统的Include、Library路径。</p>
            <p><br>　　一些小窍门</p>
            <p>　　1) 有时候，你可能在编译的时候，计算机突然非法关机了（可能某人不小心碰了电源或你的内存不稳定等原因）。当你重启机器后打开刚才的项目，重新进行编译，发现VC会崩掉。你或许以为你的VC编译器坏了，其实不然（你试试编译其它项目，还是好的！），你只要将项目的.ncb、.opt、.aps、.clw文件以及Debug、Release目录下的所有文件都删掉，然后重新编译就行<br>了。</p>
            <p>　　2) 如果你想与别人共享你的源代码项目，但是把整个项目做拷贝又太大。你完全可以删掉以下文件：.dsw、.ncb、.opt、.aps、.clw、. plg文件以及Debug、Release目录下的所有文件。</p>
            <p><br>　　3) 当你的Workspace中包含多个Project的时候，你可能不能直观地、一眼看出来哪个是当前项目。可以如下设置：Tools-&gt;Options-&gt;Format，然后在Category中选择Workspace window，改变其默认的字体（比如设成Fixedsys）就行了。</p>
            <p><br>　　4) 如何给已有的Project改名字？将该Project关掉。然后以文本格式打开.dsp文件，替换原来的Project名字即可。</p>
            <p><br>　　5) VC6对类成员的智能提示功能很有用，但有时候会失灵。你可以先关掉项目，将.clw和.ncb删掉，然后重新打开项目，点击菜单项View-&gt;ClassWizard，在弹出的对话框中按一下&#8220;Add All&#8221;按钮；重新Rebuild All。应该可以解决问题。</p>
            <p><br>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Visual C++ 编译器选项的说明：<br>///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>这些选项选择单线程或多线程运行时例程，指示多线程模块是否为 DLL，并选择运行时库的发布版本或调试版本。</p>
            <p>/MD<br>定义 _MT 和 _DLL 以便同时从标准 .h 文件中选择运行时例程的多线程特定版本和 DLL 特定版本。此选项还使编译器将库名 MSVCRT.lib 放入 .obj 文件中。 <br>用此选项编译的应用程序静态链接到 MSVCRT.lib。该库提供允许链接器解析外部引用的代码层。实际工作代码包含在 MSVCR71.DLL 中，该库必须在运行时对于与 MSVCRT.lib 链接的应用程序可用。</p>
            <p>当在定义了 _STATIC_CPPLIB (/D_STATIC_CPPLIB) 的情况下使用 /MD 时，它将导致应用程序通过静态多线程标准 C++ 库 (libcpmt.lib) 而非动态版本 (msvcprt.lib) 进行链接，同时仍通过 msvcrt.lib 动态链接到主 CRT。<br><br>/MDd<br>定义 _DEBUG、_MT 和 _DLL，以便从标准 .h 文件中选择运行时例程的调试多线程特定版本和 DLL 特定版本。它还使编译器将库名 MSVCRTD.lib 放入 .obj 文件中。 <br><br>/ML<br>使编译器将库名 LIBC.lib 放入 .obj 文件中，以便链接器使用 LIBC.lib 解析外部符号。这是编译器的默认操作。LIBC.lib 不提供多线程支持。<br><br>/MLd<br>定义 _DEBUG 并使编译器将库名 LIBCD.lib 放入 .obj 文件中，以便链接器使用 LIBCD.lib 解析外部符号。LIBCD.lib 不提供多线程支持。 </p>
            <p>/MT<br>定义 _MT，以便从标准头 (.h) 文件中选择运行时例程的多线程特定版本。此选项还使编译器将库名 LIBCMT.lib 放入 .obj 文件中，以便链接器使用 LIBCMT.lib 解析外部符号。创建多线程程序需要 /MT 或 /MD（或它们的调试等效选项 /MTd 或 /MDd）。 <br><br>/MTd<br>定义 _DEBUG 和 _MT。定义 _MT 会导致从标准 .h 文件中选择运行时例程的多线程特定版本。此选项还使编译器将库名 LIBCMTD.lib 放入 .obj 文件中，以便链接器使用 LIBCMTD.lib 解析外部符号。创建多线程程序需要 /MTd 或 /MDd（或它们的非调试等效选项 /MT 或 MD）。<br><br>/LD<br>创建 DLL。 <br>将 /DLL 选项传递到链接器。链接器查找 DllMain 函数，但并不需要该函数。如果没有编写 DllMain 函数，链接器将插入返回 TRUE 的 DllMain 函数。</p>
            <p>链接 DLL 启动代码。</p>
            <p>如果命令行上未指定导出 (.exp) 文件，则创建导入库 (.lib)；将导入库链接到调用您的 DLL 的应用程序。</p>
            <p>将 /Fe 解释为命名 DLL 而不是 .exe 文件；默认程序名成为基名称.dll 而不是基名称.exe。</p>
            <p>如果还未显式指定 /M 选项之一，则将默认运行时库支持更改为 /MT。<br><br>/LDd<br>创建调试 DLL。定义 _DEBUG。</p>
            <p>警告<br>不要混合使用运行时库的静态版本和动态版本。在一个进程中有多个运行时库副本会导致问题，因为副本中的静态数据不与其他副本共享。链接器禁止在 .exe 文件内部既使用静态版本又使用动态版本链接，但您仍可以使用运行时库的两个（或更多）副本。例如，当与用动态 (DLL) 版本的运行时库链接的 .exe 文件一起使用时，用静态（非 DLL）版本的运行时库链接的动态链接库可能导致问题。（还应该避免在一个进程中混合使用这些库的调试版本和非调试版本）。<br>有关使用运行时库的调试版本的更多信息，请参见运行时库参考。</p>
            <p>知识库文章 Q140584 也讨论如何选择适当的 C 运行时库。</p>
            <p>有关 DLL 的进一步讨论，请参见 DLL。</p>
            <p>在 Visual Studio 开发环境中设置此编译器选项</p>
            <p>打开此项目的&#8220;属性页&#8221;对话框。有关详细信息，请参见设置 Visual C++ 项目属性。 <br>单击&#8220;C/C++&#8221;文件夹。 <br>单击&#8220;代码生成&#8221;属性页。 <br>修改&#8220;运行时库&#8221;属性。 <br>以编程方式设置此编译器选项</p>
            <p>请参见 RuntimeLibrary 属性</p>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/xosen/aggbug/82462.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-05-10 12:40 <a href="http://www.cppblog.com/xosen/archive/2009/05/10/82462.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>first chance exception </title><link>http://www.cppblog.com/xosen/archive/2009/04/25/81029.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Sat, 25 Apr 2009 04:24:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/04/25/81029.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/81029.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/04/25/81029.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/81029.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/81029.html</trackback:ping><description><![CDATA[<p><span><span>译注：我们可以配置</span><strong><span><span>VS2005</span></span></strong><span>从而不显示</span><span><span>First Chance</span></span><span>异常信息。具体操作见下：</span></span></p>
<p><span><span>在</span><span><span>output</span></span><span>窗口右击，在弹出的菜单中不勾选</span><span><span>Exception messages</span></span><span>选项，这样在</span><span><span>output</span></span><span>窗口就看不到</span><span><span>First Chance</span></span><span>异常信息了。</span></span></p>
<p>&#160;</p>
<p><span></span></p>
<p><span><span>---------------------------------------------------------------</span></span></p>
<h2><span><span><span>First Chance Exception</span></span><span>是什么东东</span><span><span>?</span></span></span></h2>
<p><span><span>作者：</span><span><a href="http://blogs.msdn.com/user/Profile.aspx?UserID=3728"><span>DavidKlineMS</span></a></span><span><span> </span></span><span>翻译：飘飘白云（</span><span><span>kesalin@gmail.com</span></span><span>）</span></span></p>
<p><span><span>原文链接：</span><span><a href="http://blogs.msdn.com/davidklinems/archive/2005/07/12/438061.aspx"><span>http://blogs.msdn.com/davidklinems/archive/2005/07/12/438061.aspx</span></a></span></span></p>
<p><span>&nbsp;</span></p>
<p><span><span>调试应用程序的时候，你有没有在</span><span><span>output</span></span><span>窗口看到过&#8220;</span><span><span>First chance</span></span><span>&#8221;这样的异常消息？</span></span></p>
<p><span>&nbsp;</span></p>
<p><span><span>有曾思考过</span><span><span>: </span></span></span></p>
<ul type=disc>
    <li><span><span><span>first chance exception</span><span> </span></span><span>是什么东东</span><span><span>? </span></span></span>
    <li><span><span>出现</span><span><span> </span><span>first chance exception</span><span> </span></span><span>意味着我的代码有问题么</span><span><span>?</span></span></span> </li>
</ul>
<p><span><span><strong><span>first chance exception</span></strong><strong><span> </span></strong></span><strong><span>是什么东东</span></strong><span><strong><span>?</span></strong></span></span></p>
<p><span><span><strong></strong><strong></strong></span></span></p>
<p><span><span>调试应用程序的时候，如果引发了异常，那么调试器就会得到通知。这样，应用程序被挂起，由调试器决定如何来处理这个异常。这种机制的第一步被称之为</span><span><span> </span></span><span>&#8220;</span><span><span>first chance</span></span><span>&#8221;</span><span><span> </span></span><span>异常。根据调试器的配置，要么让应用程序继续运行并传递这个异常，要么让应用程序保持挂起状态并进入调试模式。如果应用程序处理了异常，那么应用程序将继续正常运行。</span></span></p>
<p><span><span>在</span><span><span>Visual Studio</span></span><span>里你可能会看到类似如下面这样的信息：</span></span></p>
<p><span></span></p>
<p><span><span><span>myapp.exe</span></span><span>引发了</span><span><span> </span></span><span><code><span>'System.ApplicationException'</span></code><code><span> </span></code></span><code><span>类型的</span></code><span><code><span> </span></code><code><span>A first chance</span></code><code><span> </span></code></span><code><span>异常。</span></code></span></p>
<p><span><code></code><code></code></span></p>
<p><span><span>在</span><span><span> Visual Studio 2005 Beta2</span></span><span>中，每当引发一个</span><span><span> first chance exception</span></span><span>的时候，你就会看到这条信息。如果你使用的是</span><span><span> </span><span>Visual Studio .NET 2003</span></span><span>，只有你设置了当抛出特殊异常让调试器暂停你才会看到这条消息。</span></span></p>
<p><span><span>如何应用程序没有处理这些异常（</span><span><span>first chance exception</span></span><span>），调试器会再次被通知，这就是所谓的</span><span><span> </span><span>"second chance"</span><span> </span></span><span>异常。调试器再次挂起应用程序并决定如何处理异常。通常，调试器被设置成在抛出</span><span><span> </span><span>"second chance"</span><span> </span></span><span>异常时挂起并进入调试模式，从而允许你进行调试。</span></span></p>
<p><span></span></p>
<p align=left><span><strong><span>出现</span></strong><span><strong><span> </span></strong><strong><span>first chance exception</span></strong><strong><span> </span></strong></span><strong><span>意味着我的代码有问题么</span></strong><strong><span><span>?</span></span></strong></span></p>
<p align=left><span><strong><span></span></strong></span></p>
<p align=left><span><span><span>First chance exception </span></span><span>大都时候并不意味着代码有问题。对那些优雅地处理异常的应用程序与组件来说，</span><span><span>First chance exception </span></span><span>信息让开发人员知晓一个异常被引发了并且被处理了。如果代码没有对异常进行处理，调试器将会收到</span><span><span> </span><span>second chance exception </span></span><span>通知并被未处理的异常暂停掉。</span></span></p>
<p align=left><span></span></p>
<p align=left><span><span>Take care!</span></span></p>
<p align=left><span><span>-- DK</span></span></p>
<p align=left><span></span></p>
<p><span><span>Published Tuesday, July 12, 2005 11:16 AM by </span><a href="http://blogs.msdn.com/user/Profile.aspx?UserID=3728"><span>DavidKlineMS</span></a><span> </span></span></p>
<p><span><span>Filed under: </span><a href="http://blogs.msdn.com/davidklinems/archive/tags/Debugging/default.aspx">Debugging</a></span></p>
<p>&nbsp;</p>
<img src ="http://www.cppblog.com/xosen/aggbug/81029.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-04-25 12:24 <a href="http://www.cppblog.com/xosen/archive/2009/04/25/81029.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3D的一些链接</title><link>http://www.cppblog.com/xosen/archive/2009/04/04/78910.html</link><dc:creator>xosen</dc:creator><author>xosen</author><pubDate>Fri, 03 Apr 2009 18:23:00 GMT</pubDate><guid>http://www.cppblog.com/xosen/archive/2009/04/04/78910.html</guid><wfw:comment>http://www.cppblog.com/xosen/comments/78910.html</wfw:comment><comments>http://www.cppblog.com/xosen/archive/2009/04/04/78910.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.cppblog.com/xosen/comments/commentRss/78910.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xosen/services/trackbacks/78910.html</trackback:ping><description><![CDATA[<div>
<h2><span><span><a href="http://www.gamedev.net/">http://www.gamedev.net/</a></span></h2>
<p><span>Provides news and views, articles, job offers, and more, all related to game development</span></p>
<p><span><a href="http://www.gametutorials.com/">http://www.gametutorials.com/</a></span></p>
<p><span>Tutorials for C, C++, Win32 API, DirectX, OpenGL, networking, and game development</span></p>
<p><span><a href="http://www.libsdl.org/index.php">http://www.libsdl.org/index.php</a></span></p>
<p><strong><span>&#8220;Simple <span>DirectMedia</span> Layer is a cross-platform multimedia library designed to provide level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video <span>framebuffer</span>. It is used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of &#8216;Civilization: Call <span>To</span> Power.&#8217;&#8221;</span></strong><strong></strong></p>
<p><span><a href="http://www.gamasutra.com/">http://www.gamasutra.com/</a></span></p>
<p><span>Articles from Game Developer magazine, news of the game industry (requires setting up a free <span>userid</span>)</span></p>
<p><span>Organizations and Conferences</span></p>
<p><span><a href="http://www.igda.org/">http://www.igda.org/</a></span></p>
<p><span>Organization for game developers&#8230;membership is $100/year, $35/year for students, and includes <strong><em>Game Developer</em></strong> magazine</span></p>
<p><span><a href="http://www.gamanetwork.com/">http://www.gamanetwork.com/</a></span></p>
<p><span>Parent organization for <span>Gamasutra</span> Online, Game Developer magazine, and the game developer&#8217;s conference</span></p>
<p><span><a href="http://www.gdconf.com/">http://www.gdconf.com/</a></span></p>
<p><span>Annual game developer&#8217;s conference</span></p>
<p><span><a href="http://www.igf.com/">http://www.igf.com/</a></span></p>
<p><span>Independent Games Festival&#8230;contest for independent game developers, and a student showcase to highlight work of high school and college game developers</span></p>
<p><span><a href="http://www.garagegames.com/">http://www.garagegames.com/</a></span></p>
<p><span>Home of independent games and game makers</span></p>
<p><span>3D Graphics Libraries</span></p>
<p><span><a href="http://www.microsoft.com/windows/directx/default.aspx">http://www.microsoft.com/windows/directx/default.aspx</a></span></p>
<p><span>Microsoft DirectX information site</span></p>
<p><span><a href="http://www.opengl.org/">http://www.opengl.org/</a></span></p>
<p><span>OpenGL information site (code samples, tutorials, etc)</span></p>
<p><span><a href="http://www.xmission.com/~nate/opengl.html">http://www.xmission.com/~nate/opengl.html</a></span></p>
<p><span><span>Nate</span></span><span> Robins OpenGL site, containing precompiled GLUT for Windows, tutorials, etc</span></p>
<p><span><a href="http://www.mathies.com/cpw/about.html">http://www.mathies.com/cpw/about.html</a></span></p>
<p><span>Free GLUT API replacement for game programming</span></p>
<p><span><a href="http://hem.passagen.se/opengl/glfw/">http://hem.passagen.se/opengl/glfw/</a></span></p>
<p><span>Another GLUT replacement OpenGL framework for Windows and Unix/X11</span></p>
<p><span>3D Graphics Engines</span></p>
<p><span><a href="http://cg.cs.tu-berlin.de/~ki/game_eng.html">http://cg.cs.tu-berlin.de/~ki/game_eng.html</a></span></p>
<p><span>3D engines list, last updated </span><st1:date Year="2000" Day="23" Month="6"><span>6/23/2000</span></st1:date><span>&#8230;lists 643 engines</span></p>
<p><span><a href="http://www.cs.tu-berlin.de/~ki/game_eng.html">www.cs.tu-berlin.de/~ki/game_eng.html</a></span></p>
<p><span>Commercial 3D game engines list, last updated </span><st1:date Year="1997" Day="16" Month="5"><span>5/16/97</span></st1:date></p>
<p><span><a href="http://www.slamsoftware.com/">http://www.slamsoftware.com/</a></span></p>
<p><span>Amp 2 game engine&#8230;licenses start at $200</span></p>
<p><span><a href="http://www.c4engine.com/">http://www.c4engine.com/</a></span></p>
<p><span>Graphics license, $3000, sound license $2000, network license $2000</span></p>
<p><span><a href="http://www.ca3d-engine.de/">http://www.ca3d-engine.de/</a></span></p>
<p><span>Free for free <span>mods</span>, need to negotiate a license for commercial use</span></p>
<p><span><a href="http://crystal.sourceforge.net/">http://crystal.sourceforge.net/</a></span></p>
<p><span>Free game development kit in C++&#8230;multiplatform, using OpenGL</span></p>
<p><span><a href="http://www.exocortex.org/3dengine/">http://www.exocortex.org/3dengine/</a></span></p>
<p><span>Graphics engine using OpenGL and C# that started as a class project&#8230;includes support for Cg <span>shader</span> programming</span></p>
<p><span><a href="http://www.fly3d.com.br/">http://www.fly3d.com.br/</a></span></p>
<p><span>The Fly3D libraries (v1 and v2) from the 3D Games books by Watt and <span>Policarpo</span>&#8230;Fly3D v1.02 is free for commercial and noncommercial use, while Fly3D v2 is available for free under the GPL if the resulting game is also GPL, or for a fee for a single game use without royalties</span></p>
<p><span><a href="http://www.wirewd.com/wh/glvr.html">http://www.wirewd.com/wh/glvr.html</a></span></p>
<p><span>GLVR library for entertainment VR, in particular games, written in C++</span></p>
<p><span><a href="http://www.hyzgame.com/English/index.htm">http://www.hyzgame.com/English/index.htm</a></span></p>
<p><span>2D/3D game library from </span><st1:country-region><st1:place><span>China</span></st1:place></st1:country-region></p>
<p><span><a href="http://www.panardvision.com/v3/pv_overview.php">http://www.panardvision.com/v3/pv_overview.php</a></span></p>
<p><span><span>Panard</span></span><span> Vision, free for noncommercial use</span></p>
<p><span><a href="http://www.garagegames.com/pg/product/view.php?id=1">http://www.garagegames.com/pg/product/view.php?id=1</a></span></p>
<p><span>Torque game engine, including networking, GUI builder, world editor and scripting language&#8230;includes full source code for game engine&#8230;$100 per programmer with no royalties to use for any company with less than $500,000 in sales&#8230;the engine used in Tribes, Tribes2, <span>Starsiege</span>, etc</span></p>
<p><span><a href="http://www.v3x.net/v3x/v3x_3d_engine.html">http://www.v3x.net/v3x/v3x_3d_engine.html</a></span></p>
<p><span>V3x.net engine&#8230;free for freeware or evaluation, 5000 Euros for 1 game, 15000 Euros for unlimited games<span>, ???</span> <span>for</span> unlimited usage with source code</span></p>
<p><span><a href="http://www.idsoftware.com/business/home/technology/index.php">http://www.idsoftware.com/business/home/technology/index.php</a></span></p>
<p><span>Quake engine and tools are available for free under the GPL, or for a flat fee of $10000 per title with no royalties&#8230;Quake II engine is available for free under the GPL, or for a flat fee of $10000 per title with no royalties&#8230;.Quake II tools are NOT GPL, and are for noncommercial use only, or can be licensed for $5000 a project&#8230;Quake III engine is $250000 guarantee against a 5% royalty of the wholesale title price</span></p>
<p><span><a href="http://www.magic-software.com/">http://www.magic-software.com/</a></span></p>
<p><span>Wild Magic game engine, from Dave <span>Eberly&#8217;s</span> book&#8230;free for noncommercial projects, or for commercial products that do more than just sell the game engine</span></p>
<p><span>Game information sites</span></p>
<p><span><a href="http://www.gamesdomain.com/indexus.html">http://www.gamesdomain.com/indexus.html</a></span><span> </span></p>
<p><span><a href="http://www.3davenue.com/">http://www.3davenue.com/</a></span></p>
<p>&nbsp;</p>
<p><span>Books of Interest</span></p>
<p><strong><span>Game Programming Gems</span></strong><span>, Mark <span>DeLoura</span>, editor, August 2000, Charles River Media, ISBN 1584500492</span></p>
<p><strong><span>Game Programming Gems 2</span></strong><span>, Mark <span>DeLoura</span>, editor, October 2001, Charles River Media, ISBN 1584500549</span></p>
<p><strong><span>Game Programming Gems 3</span></strong><span>, Dante <span>Treglia</span> and Mark <span>DeLoura</span>, editors, July 2002, Charles River Media, ISBN 1584502339</span></p>
<p><span>An attempt to be to game development what <strong>Graphics Gems</strong> is to computer graphics in general</span></p>
<p><strong><span>AI Game Programming Wisdom</span></strong><span>, Steve Rabin, editor, March 2002, Charles River Media, ISBN 1584500778</span></p>
<p><strong><span>Mathematics for 3D Game Programming &amp; Computer Graphics</span></strong><span>, Eric <span>Lengyel</span>, December 2001, </span><st1:place><span>Charles River</span></st1:place><span> Media, ISBN 1584500379</span></p>
<p><strong><span>The Cg Tutorial: The Definitive Guide to Programmable Real-Time Graphics</span></strong><span>, <span>Randima</span> Fernando and Mark <span>Kilgard</span>, February 2003, Addison-Wesley, ISBN 0321194969</span></p>
<p><strong><span>Real-Time <span>Shader</span> Programming</span></strong><span>, Ron <span>Fosner</span>, December 2002, Morgan Kaufmann, ISBN 1558608532</span></p>
<p><strong><span>Real-Time Rendering</span></strong><span>, 2<sup>nd</sup> edition, Tomas <span>Akenine-Moller</span> &amp; Eric Haines, July 2002, AK Peters, ISBN 1568811829</span></p>
<p><strong><span>Physics for Game Developers</span></strong><span>, David Bourg, November 2001, O&#8217;Reilly &amp; Associates, ISBN 0596000065</span></p>
<p><strong><span>3D Game Engine Design: A Practical Approach to Real-Time Computer Graphics</span></strong><span>, David <span>Eberly</span>, September 2000, Morgan Kaufmann, ISBN 1558605932</span></p>
<p><strong><span>3D Games: Real-Time Rendering and Software Technology</span></strong><span>, Volume 1, Alan Watt and Fabio <span>Policarpo</span>, December 2000, Addison Wesley, ISBN 0201619210</span></p>
<p><strong><span>3D Games: Animation and Advanced Real-Time Rendering</span></strong><span>, Volume 2, Alan Watt and Fabio <span>Policarpo</span>, January 2003, Addison Wesley, ISBN 0201787067<br><br>上述资料取自<a href="http://employees.oneonta.edu/allisodl/GameDevelopment/">http://employees.oneonta.edu/allisodl/GameDevelopment/</a>，所有权利归原出处所有，这里谨做链接。</span></p>
</span></div>
<img src ="http://www.cppblog.com/xosen/aggbug/78910.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xosen/" target="_blank">xosen</a> 2009-04-04 02:23 <a href="http://www.cppblog.com/xosen/archive/2009/04/04/78910.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>