亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? chapter3.html

?? WRITING BUG-FREE C CODE.
?? HTML
?? 第 1 頁 / 共 3 頁
字號:
<b>Porting aids for Microsoft C8 segmented architecture</b>#define FAR _far#define NEAR _near#define FASTCALL _fastcall#define PASCAL _pascal#define EXPORT _export#define BASEDIN(seg) _based(_segname(#seg))<br><b>Porting aids for flat model programs</b>#define FAR#define NEAR#define FASTCALL#define PASCAL#define EXPORT#define BASEDIN(seg)</pre></tr></td></table> <br>FAR and NEAR.  These are used to abstract out the near- and far-segmented architecture.  NEAR implies a 16-bit pointer and FAR implies a 32-bit pointer.  When porting to a non-segmented architecture, these can be defined to be nothing. <br><br>FASTCALL and PASCAL.  These are used to specify the calling convention of a function primarily for optimization purposes.  When porting to a non-segmented architecture, these can be defined to be nothing. <br><br>EXPORT.  This define is applicable to Windows DLL programming.  Otherwise, it can be defined to be nothing. <br><br>BASEDIN.  This define is primarily used by the CSCHAR macro to place character strings within a code segment primarily for optimization purposes.  When porting to a non-segmented architecture, it can be defined to be nothing. <br><br>In most cases, these macros are used in other macros or in typedef's so that the code base is not cluttered up.  For example, to declare a far pointer to a char so that it works equally well under a segmented and non-segmented architecture, you could do the following. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Using a far pointer to a char, not a good idea</b>char FAR*lpMem;</pre></tr></td></table> <br>However, using char FAR* will just clutter up all the source files with FAR.  The solution is to use a typedef to declare what a far pointer to a char is once. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>LPSTR typedef, a better idea</b>typedef char FAR*LPSTR;</pre></tr></td></table> <br>Now LPSTR should be used instead of char FAR*.  The concept of trying to hide how something works provides an abstraction that aids porting and allows for clean source code.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Try to hide how something works to provide an abstraction that aids   </tr></td></table></blockquote> <br><br><b>3.2.2 Using EXTERNC</b> <br><br>If you are coding under C++, name mangling can sometimes be a problem.  This happens under Windows DLL coding when a .def file is used.  Functions that are exported must be specified in the .def file, but name mangling can make it almost impossible to type in the names manually.  Luckily, C++ provides a solution in the form of a linkage specification.  The #define's you can use are as follows. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>EXTERNC macro</b>/*--- EXTERNC depends upon C/C++ ---*/#ifdef __cplusplus#define EXTERNC extern "C"#else#define EXTERNC#endif</pre></tr></td></table> <br>Under C++, EXTERNC gets defined to be extern "C".  Under C, EXTERNC gets defined to be nothing.  EXTERNC is used in function prototypes as follows. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Using EXTERNC</b>EXTERNC type APIENTRY FunctionName( argument-types );</pre></tr></td></table> <br>You need to use EXTERNC only in the prototype for a function, not in the source code where the function is actually written.  This is how Microsoft C8 works.<br><a name="winassert"><br></a><big><b>3.3 Using WinAssert() Statements</b></big> <br><br>The WinAssert() statement is the classic assertion statement with a few twists.  Why use assertion statements?  The key reason is to verify that decisions and assumptions made at design-time are working correctly at run-time.  There is a difference between WinAssert() and <a href="chapter2.html#compilerassert">CompilerAssert() &sect;2.1.4</a>. Both check design-time assumptions, but CompilerAssert() provides the check at compile-time, whereas  WinAssert() provides the check at run-time.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Assertion statements provide run-time checking of design-time   assumptions.   </tr></td></table></blockquote><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Microsoft C8 assert() macro, do not use</b>#define assert(exp) \  ( (exp) ? (void) 0 : _assert(#exp, __FILE__, __LINE__) )</pre></tr></td></table> <br>An assert macro is provided by the Microsoft C8 library in assert.h.  It takes any boolean expression.  Nothing happens when the assert macro is true.  If the assert macro is false, however, the _assert() function is called with a string pointer to the text of the boolean expression, a string pointer to the text of the source file and an integer line number where the error occurred.  Usage of the stringizing operator (#) is described in <a href="chapter2.html#stringizing">&sect;2.2.7</a> .  This information is then formatted and displayed by _assert(). <br><br>A problem with this macro is that it ends up placing too many strings in the default data segment.  One easy solution is to remove the #exp argument, which is turning the boolean expression into text.  After all, the file and line number are all that are needed to look up the boolean expression.  Also, every time the assert() macro is used, a new string __FILE__ is created.  Some compilers are able to optimize these multiple references into one reference, but why not just fix the problem?  My solution to the problem is to declare a short stub function at the top of each source file which references __FILE__.  WinAssert() then calls this stub function with the current line number. <br><br><table bgcolor="#F0F0F0"><tr><td><img src="./windows.gif">There is an additional problem that is specific to the Windows programming environment.  In Windows DLLs, it is possible to declare a function that, when called, does not switch to the DLLs data segment, but instead keeps the current caller's data segment.  If you were to use an assertion statement in one of these functions, the string pointer to the filename would be incorrect.  The solution is to declare the __FILE__ string to be a code segment (<a href="chapter2.html#cschar">CSCHAR &sect;2.1.8</a>) variable.  This way, it does not matter what data segment is current. </td></tr></table> <br>An interesting twist that has been added to WinAssert() is that it supports writing code that is fault-tolerant.  If a design-time assumption has failed, should you really be executing a section of code?  I say no!  The WinAssert() statement may be followed by a semicolon or by a block of code.  The block of code will be executed only if the assertion succeeds.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Use WinAssert() on a block of code to produce code that is   fault-tolerant.   </tr></td></table></blockquote><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>WinAssert(), non-fault-tolerant syntax</b>WinAssert(expression);<br><b>WinAssert(), fault-tolerant syntax</b>WinAssert(expression) {    (block of code)    }</pre></tr></td></table><br>The WinAssert() is implemented through a set of macros as follows.<br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>WinAssert() implementation</b>#define USEWINASSERT CSCHAR szSRCFILE[]=__FILE__;   \  BOOL static NEAR _DoWinAssert( int nLine ) {      \    ReportWinAssert(szSRCFILE, nLine);              \    WinAssert(nLine);                               \    return(FALSE);                                  \    }#define AssertError _DoWinAssert(__LINE__)#define WinAssert(exp) if (!(exp)) {AssertError;} else</pre></tr></td></table> <br>If WinAssert() is used in a source file, USEWINASSERT must appear at the top of the source file somewhere. <br><br>In addition to the WinAssert() macro, an AssertError() macro is provided for those times that you want to unconditionally force an error to be reported. <br><br>The reporting process of an assertion failure starts by calling a function that is local (private) to the source file.  The function is _DoWinAssert() and the argument is the line number where the failure occurred.  The body of _DoWinAssert() is straightforward except for the inclusion of WinAssert(nLine).  Since the line number is never zero, this appears to have no purpose.  This trick forces _DoWinAssert() to be compiled into the module, even if there are no references to the function in the rest of the file.  Otherwise, Microsoft C8 removes the unreferenced function. <br><br>Another subtle problem is that if _DoWinAssert() is declared to be a LOCAL function (described in <a href="chapter6.html">Chapter 6</a>), the optimizing Microsoft C8 compiler will not build a stack frame for this function.  For this reason, it has the static NEAR attributes instead of the LOCAL attribute, which allows the stack frame to be built. <br><br>In addition to these defines, WinAssert() requires that ReportWinAssert() be defined somewhere.  I define it in a DLL so that the function needs to be coded only once. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>ReportWinAssert() function prototype</b>EXTERNC void APIENTRY ReportWinAssert( LPSTR, int );</pre></tr></td></table> <br>Once done, any other application has access to it.  ReportWinAssert() allows you to display the assertion error in whatever way is appropriate at your organization.  In my ReportWinAssert(), I log the filename, line number and stack trace to a log file and issue a system modal message box requesting that the user report the error. See <a href="appendix.html#reportwinassert">&sect;A.7</a> for example implementations. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Using WinAssert()</b>#include &lt;app.h&gt;USEWINASSERT  .  .  .void LOCAL TestingWinAssert( int nValue ){    WinAssert(nValue&gt;0) {        ...        }} /* TestingWinAssert */</pre></tr></td></table> <br>One of the key things you must remember is that the argument to WinAssert() must have absolutely no side effect on any variables.  It must only reference variables. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>WinAssert(), used incorrectly</b>WinAssert((x/=2)&gt;0);<br><b>WinAssert(), used correctly</b>x /= 2;WinAssert(x&gt;0);</pre></tr></td></table> <br>This is in case a policy of removing asserting statements from the code before releasing the product is enforced.  While I do not

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品成a人| 一区二区三区国产| 欧美一区日韩一区| 欧美视频三区在线播放| 在线精品国精品国产尤物884a| 成人免费三级在线| 成人黄色在线看| 成人午夜大片免费观看| 成人av网址在线| 色噜噜狠狠成人中文综合 | 欧美视频一区二区三区四区| 色综合久久久久综合体桃花网| 色婷婷综合久久久久中文一区二区 | 久久一日本道色综合| 亚洲精品一区在线观看| 国产欧美日韩精品在线| 亚洲欧美一区二区在线观看| 一区二区在线观看视频 | 国产亚洲综合在线| 国产精品丝袜黑色高跟| 一卡二卡三卡日韩欧美| 久久精品久久综合| 成熟亚洲日本毛茸茸凸凹| 在线亚洲一区观看| 欧美一区二区在线看| 国产午夜亚洲精品羞羞网站| 亚洲视频香蕉人妖| 日本怡春院一区二区| 成人综合婷婷国产精品久久蜜臀| 91九色最新地址| 日韩欧美一区电影| 国产精品不卡一区| 日韩 欧美一区二区三区| 国产成a人亚洲精| 欧美三级日韩三级| 欧美国产一区视频在线观看| 午夜精品久久久久久久久久久| 国产福利一区二区三区视频| 欧美视频中文一区二区三区在线观看| 日韩精品资源二区在线| 国产精品久久精品日日| 日韩电影在线免费| 91麻豆自制传媒国产之光| 亚洲精品在线免费观看视频| 午夜精品久久久久久不卡8050| 粉嫩嫩av羞羞动漫久久久| 日韩欧美在线观看一区二区三区| 成人欧美一区二区三区在线播放| 蜜桃精品在线观看| 欧美最猛黑人xxxxx猛交| 久久精品一区八戒影视| 青青草视频一区| 欧美综合亚洲图片综合区| 欧美国产1区2区| 老司机午夜精品99久久| 欧美性猛片aaaaaaa做受| 中文字幕一区二区在线观看| 美女精品自拍一二三四| 欧美精品123区| 亚洲五码中文字幕| 91精彩视频在线观看| 国产精品久久久久久久久动漫| 精品一区二区三区欧美| 日韩欧美亚洲国产精品字幕久久久| 亚洲一区二区高清| 色婷婷av一区二区三区大白胸| 国产精品久久一卡二卡| 国产成人精品影院| 欧美极品另类videosde| 国产剧情av麻豆香蕉精品| 精品福利一二区| 久久99久国产精品黄毛片色诱| 911国产精品| 另类调教123区| 26uuu另类欧美| 国产激情一区二区三区| 久久久精品免费观看| 国产精品资源在线| 国产午夜久久久久| 不卡一区二区中文字幕| 亚洲精品成人少妇| 精品视频免费在线| 日本成人中文字幕| 久久久久久97三级| av电影在线观看不卡 | 欧美三级三级三级爽爽爽| 亚洲午夜精品网| 日韩精品中文字幕一区| 国产剧情在线观看一区二区| 国产精品你懂的在线欣赏| 99视频一区二区| 亚洲制服丝袜在线| 日韩一区和二区| 国产福利91精品一区二区三区| 亚洲欧洲在线观看av| 欧美日韩亚洲综合| 国产剧情在线观看一区二区| 国产精品美女久久久久久久久久久 | 99久久国产免费看| 亚洲一级片在线观看| 精品日韩一区二区三区免费视频| 国产不卡在线播放| 亚洲午夜一区二区| 国产欧美日韩在线视频| 91福利在线导航| 久久成人av少妇免费| 亚洲乱码国产乱码精品精可以看 | 国产精品一二三四| 一区二区三区日本| 欧美精品一区在线观看| 91小宝寻花一区二区三区| 秋霞成人午夜伦在线观看| 国产精品免费av| 日韩一级高清毛片| 91麻豆免费看| 国产一区二区福利| 午夜电影久久久| 椎名由奈av一区二区三区| 欧美一级国产精品| 91麻豆123| 成熟亚洲日本毛茸茸凸凹| 日韩av在线播放中文字幕| 亚洲日本在线看| 久久久www免费人成精品| 欧美日韩mp4| 一本一道波多野结衣一区二区| 精品午夜一区二区三区在线观看| 亚洲午夜久久久| 亚洲精品视频自拍| 欧美激情资源网| 久久在线观看免费| 日韩欧美区一区二| 欧美巨大另类极品videosbest | 韩国女主播成人在线观看| 一区二区在线观看免费视频播放 | 色国产综合视频| 成人污污视频在线观看| 国产精品一区二区你懂的| 青青青伊人色综合久久| 丝袜美腿亚洲色图| 亚洲第一成人在线| 亚洲国产欧美在线人成| 国产精品久久久久久久蜜臀| 日本一区二区视频在线| 久久免费视频色| 久久久久亚洲蜜桃| 久久久精品综合| 国产清纯白嫩初高生在线观看91| 欧美videossexotv100| 日韩一区二区精品在线观看| 欧美巨大另类极品videosbest | 欧美岛国在线观看| 精品少妇一区二区三区日产乱码 | 亚洲美女偷拍久久| 亚洲影院久久精品| 亚洲综合色视频| 丝袜亚洲另类丝袜在线| 日本美女一区二区| 国产一区在线不卡| eeuss鲁片一区二区三区在线观看| 粉嫩av一区二区三区粉嫩| 99精品国产91久久久久久| 色婷婷香蕉在线一区二区| 欧美三级在线播放| 欧美tickling网站挠脚心| 久久久久久久久久久电影| 国产精品伦一区二区三级视频| 亚洲精品国产品国语在线app| 亚洲国产一区二区视频| 男男视频亚洲欧美| 国产精品正在播放| 色又黄又爽网站www久久| 在线观看91精品国产麻豆| 久久久久久毛片| 亚洲欧美日韩国产一区二区三区| 亚洲成人黄色影院| 激情小说亚洲一区| 91麻豆swag| 日韩一区二区三区精品视频| 亚洲国产精品传媒在线观看| 一区二区在线观看视频在线观看| 日韩国产精品大片| 成人激情电影免费在线观看| 精品视频色一区| 国产性做久久久久久| 亚洲一区二区视频在线| 国产一区日韩二区欧美三区| 97精品久久久午夜一区二区三区| 7777精品伊人久久久大香线蕉完整版| 久久久久久久综合日本| 亚洲在线视频网站| 成人综合激情网| 日韩视频一区二区在线观看| 18欧美乱大交hd1984| 久久精品噜噜噜成人av农村| 在线看不卡av| 国产精品视频九色porn| 久草精品在线观看| 欧洲人成人精品| 中文字幕一区二区三中文字幕|