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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chapter2.html

?? WRITING BUG-FREE C CODE.
?? HTML
?? 第 1 頁 / 共 5 頁
字號:
<html><head><title>Writing Bug-Free C Code: Know Your Environment</title></head><body><center><font size="+3">Chapter 2: Know Your Environment</font><br><a href="index.html">Writing Bug-Free C Code</a><br></center><br><center><table><tr><td valign=top><small><a href="#theclanguage">2.1 The C Language</a><br><a href="#cpreprocessor">2.2 C Preprocessor</a><br><a href="#puzzles">2.3 Programming Puzzles</a><br><small></td><td width=30>&nbsp;</td><td valign=top><small><a href="#windows">2.4 Microsoft Windows</a><br><a href="#summary">2.5 Chapter Summary</a><br></small></td></tr></table></center><br><br>Before you can efficiently institute new programming methodologies that help eliminate bugs, you need to understand the features available to you in your programming environment. <br><br>Quite often, it is beneficial to ask yourself why a particular feature is present in the environment.  If you are already using the feature, great, but is there another way you could also be using it?  If you are not using the feature, try to think of why the feature was added, because someone needed and requested the feature.  Why did they need the feature and how are they using it?   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Try to become an expert in your environment.   </tr></td></table></blockquote>In the process of learning about all the features of your environment, you may eventually become an expert on it.  And the learning process never stops.  With each new version of the tools in your environment, look in the manuals to find out what new features have been added.  Sometimes features are even removed!<br><a name="theclanguage"><br></a><big><b>2.1 The C Language</b></big> <br><br><table bgcolor="#F0F0F0"><tr><td><img src="./windows.gif">Microsoft C 8.0 (a.k.a. Microsoft Visual C++ 1.0) comes in two editions: the standard edition and the professional edition.  The standard edition is targeted to the part-time programmer, the professional edition to the full-time programmer.  The professional edition comes with more manuals and, more important, the Windows 3.1 SDK. </td></tr></table> <br>No matter which C compiler you are using, it is important that you fully understand the C programming environment. <br><br><b>2.1.1 The Array Operator</b> <br><br>You've used the array operator to index an array before, but have you given any thought to how the compiler interprets the array operator?  You may not know how it does, especially if you learned C after learning another language first! <br><br>Suppose you have a character array called buffer and an integer <tt>nIndex</tt> used to index into the character array.  How do you obtain a character from the character array?  Most everyone will tell you <tt>buffer[nIndex]</tt>, namely, the array name followed by the array index in brackets. <br><br>Did you know that <tt>nIndex[buffer]</tt> also works!  This syntax is not recommended, but it does work.  Do you know why? <br><br>The reason that <tt>buffer[nIndex]</tt> references the same character as <tt>nIndex[buffer]</tt> is clearly stated in &sect;A7.3.1 of <a href="references.html">The C Programming Language (2nd ed.)</a> as follows: <blockquote><i> A postfix expression followed by an expression in square brackets is a postfix expression denoting a subscripted array reference.  One of the two expressions must have type "pointer to T", where T is some type, and the other must have integral type; the type of the subscript expression is T.  The expression E1[E2] is identical (by definition) to *((E1)+(E2)). </i></blockquote>The key to understanding array references is to understand "The expression E1[E2] is identical (by definition) to *((E1)+(E2))."  In terms of the example, buffer[nIndex] is identical to *((buffer)+(nIndex)).  Addition is commutative (i.e., 3 + 4 equals 4 + 3), which makes *((buffer)+(nIndex)) identical to *((nIndex)+(buffer)), which is nIndex[buffer].   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Array reference E1[E2] is identical to *((E1)+(E2)).   </tr></td></table></blockquote><b>2.1.2 The Structure Pointer Operator</b> <br><br>You all know that if p is a pointer to a structure, that p-&gt;structure-member refers to a particular member of the structure.  Suppose that you could no longer use the structure pointer operator -&gt;.  Could you somehow use the other operators in C and continue coding? <br><br>The answer is yes.  Instead of p-&gt;structure-member, use (*p).structure-member.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   If p is a pointer to a structure, the structure reference p-&gt;member   is identical to (*p).member.   </tr></td></table></blockquote>Again, this is not a recommended syntax, but it is good to understand that it does work and why it works.  It is spelled out in &sect;A7.3.3 of <a href="references.html">The C Programming Language</a>. <br><br><a name="c8warning"></a><table bgcolor="#F0F0F0"><tr><td><img src="./windows.gif"> <b>2.1.3 Use the Highest Compiler Warning Level</b> <br><br>The warning and error messages of the Microsoft C compiler are getting better with each release of the compiler.  I strongly recommend that you compile your code at the highest warning level available to you.  For Microsoft C8, this is warning level four.  The command line option for this is /W4. <br><br>At warning level four, there may be some warning messages that you want to totally ignore.  An example in Microsoft C8 are warnings produced by unused declared inline functions.  I declare my inline functions in an include file.  The source files then use only those inline functions that are needed.  Unfortunately, the unreferenced inline functions produce the unreferenced local function has been removed warning message, which is warning number C4505.  To disable this warning, you can use the warning #pragma in your include files. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Pragma to disable warning number 4505 in Microsoft C8</b>#pragma warning(disable:4505)</pre></tr></td></table><br>Some of the useful, interesting warning messages that you can get from the Microsoft C8 compiler are as show in Table 2-1.<br><br><ul><table border=1 cellspacing=0><tr><td><b>Error Number</b></td><td><b>Error Message</b></td></tr><tr><td>C4019</td><td>empty statement at global scope</td></tr><tr><td>C4100</td><td>unreferenced formal parameter</td></tr><tr><td>C4101</td><td>unreferenced local variable</td></tr><tr><td>C4701</td><td>local variable "identifier" may be used without having been initialized.  This warning is given only when compiling with the C8 /Oe global register allocation command-line option.</td></tr><tr><td>C4702</td><td>unreachable code.  This warning is given only when compiling with one of the C8 global optimization options (/Oe, /Og or /Ol)</td></tr><tr><td>C4705</td><td>statement has no effect</td></tr><tr><td>C4706</td><td>assignment within conditional expression</td></tr><tr><td>C4723</td><td>potential divide by 0</td></tr></table>Table 2-1: Some interesting Microsoft C8 warning messages.</ul></td></tr></table><br><a name="compilerassert"></a><b>2.1.4 CompilerAssert()</b> <br><br>CompilerAssert() is designed to provide error checking at compile-time for assumptions made by the programmer at design-time.  These assumptions must be documented within comments in the code as well, but why not also have a compile-time check made whenever possible? <br><br>The reasoning behind this is simple.  What if a new programmer is working on a section of code in which an assumption is made and the programmer inadvertently changes the code so that the assumption is now invalid?  The bug may not show up for a long time.  However, if the problem could have been flagged at compile-time, it would have saved a lot of time and effort.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Use CompilerAssert() to verify design-time assumptions at   compile-time.   </tr></td></table></blockquote>The trick in designing CompilerAssert() is to do it in such a way so that the compiler catches the error at compile-time and yet does not produce any run-time code. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>CompilerAssert() define</b>#define CompilerAssert(exp) extern char _CompilerAssert[(exp)?1:-1]</pre></tr></td></table> <blockquote><small><i><font color="blue"> UPDATE: (exp)?1:-1 used to be (exp)?1:0 but it appears that there are some UNIX C compilers that do <u>not</u> complain about an array of zero length even though the standard says the array size must be greater than zero. So 0 was changed to -1 because every compiler must complain about an array with negative size. </i></font></small></blockquote>This CompilerAssert() works because it is really just an array declaration and the array bound for an array declaration must be a constant expression that is greater than zero.  This is documented in &sect;A8.6.2 of <a href="references.html">The C Programming Language</a>. Using extern makes sure that no code is generated. <br><br>The argument that you pass to CompilerAssert() should be a boolean expression.  This means that it evaluates to zero or one.  If it is one, the CompilerAssert() is valid and so is the array declaration.  If it is zero, the CompilerAssert() is invalid and so is the array declaration.  This will cause the compiler to notify you of an error and the compilation will stop. <br><br>An added bonus is that the argument to CompilerAssert() must be able to be evaluated at compile-time because the array bound of the array declaration must be a constant expression.  This makes it impossible for you to misuse CompilerAssert() and have it accidentally generate some code. <br><br>Another bonus is that CompilerAssert() is not limited to use only in functions or source files.  It can even be used in include files as needed! <br><br>It can also be used more than once in the same scope with no problems.  This is due to the usage of extern.  Using extern declares the type of _CompilerAssert; it does not define it.  Declaring the type of a variable name more than once is OK (as long as the data type is the same).  Also, the array size of (exp)?1:-1 changes any non-zero (exp) to one.  If this were not done and two different (exp) values were used by two CompilerAssert()'s, the compiler would complain. <br><br>Some linkers may require that a _CompilerAssert variable exist while other linkers will optimize out the declared but unused variable.  If the linker that you use requires a _CompilerAssert variable, place char _CompilerAssert[1]; in any one of your source files to fix the linker error.  The linker that comes with Microsoft C8 does not require this fix. <br><br>Let's say that you have coded a function that for some reason requires an internal buffer to be a power of two.  Assuming that an <a href="#ispower2">ISPOWER2() macro</a> already exists, how would you CompilerAssert() this? <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Sample CompilerAssert() usage</b>...char buffer[BUFFER_SIZE];...CompilerAssert(ISPOWER2(sizeof(buffer)));...</pre></tr></td></table> <br>You should test CompilerAssert() to verify that it is working in your environment.  Under Microsoft C8 and UNIX, the following program will produce a 'negative subscript' error message when compiled. <br><br><table bgcolor="#CCCCEE" cellpadding=0 cellspacing=0><tr><td><pre><b>Testing CompilerAssert(), file test.c</b>#define CompilerAssert(exp) extern char _CompilerAssert[(exp)?1:-1]int main(void){    /*--- A forced CompilerAssert ---*/    long lVal;    CompilerAssert(sizeof(lVal)==0);    return 0;} /* main */ <br><br><b>Compiling test.c under Microsoft C8, should produce an error C2118</b>cl test.c<font color="blue">test.c(7) : error C2118: negative subscript</font> <br><br><b>Compiling test.c under UNIX cc, should produce an error message</b>cc test.c<font color="blue">test.c: In function `main':test.c:7: size of array `_CompilerAssert' is negative</font></pre></tr></td></table> <br><b>2.1.5 Variable Declarations</b> <br><br>Have you ever wondered why you have to declare c is a pointer to a char as char*c?  Do you know if there is a difference between char buffer[80] and char (*buffer)[80]?  At first, C's declaration syntax may appear difficult, but there is a structure behind it that I am going to try to explain.  I firmly believe that the better you understand it, the better C programmer you will be. <br><br>What is the result of 2 + 3 * 5?  It is 17, but why?  Why did you multiply before you added?  The answer is that there is a precedence relationship among the operators.  What is the result of (2 + 3) * 5?  It is 25 because the parentheses override the natural precedence relationship.  There is a direct analogy to reading C variable declarations. <br><br>You have basically four things to look for:  First, parentheses, (...);  second, arrays, [...];  third, functions, ();  fourth, pointers, *.  The parentheses, just as in expressions, can override precedence relationships.  Arrays [] and functions () have a higher precedence than pointers *.  Since arrays and functions always appear to the right of a variable name in a declaration and pointers always appear to the left of the variable name, this in effect tells you that you always move right before moving left when reading the variable declaration.   <blockquote><table bgcolor="#E0E0E0" border=1 cellpadding=2 cellspacing=0><tr><td>   Always try to move right before moving left when reading a variable   declaration.   </tr></td></table></blockquote>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天综合给合国产| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 久久精品亚洲精品国产欧美| 在线91免费看| 精品伦理精品一区| 精品va天堂亚洲国产| 国产日韩亚洲欧美综合| 中文在线免费一区三区高中清不卡| 精品日韩在线一区| 国产人伦精品一区二区| 国产精品每日更新在线播放网址| 日韩毛片精品高清免费| 亚洲宅男天堂在线观看无病毒| 一个色综合av| 蜜臀91精品一区二区三区| 国产精品白丝jk黑袜喷水| 99久久精品国产导航| 欧美日韩一区二区不卡| 精品久久久久一区二区国产| 国产调教视频一区| 亚洲欧洲日韩av| 性欧美大战久久久久久久久| 韩国v欧美v日本v亚洲v| 91免费视频网| 精品国产乱码久久久久久牛牛| 国产精品久久久久婷婷| 亚洲五码中文字幕| 黄色小说综合网站| 99久久精品久久久久久清纯| 欧美三级欧美一级| 久久伊99综合婷婷久久伊| 国产精品人妖ts系列视频| 亚洲成年人影院| 成人黄页毛片网站| 欧美日韩在线电影| 中文字幕制服丝袜成人av| 免费在线观看一区| 99久久精品国产一区二区三区| 91精品在线观看入口| 国产精品动漫网站| 老汉av免费一区二区三区 | 亚洲第一二三四区| 国产精品一二三| 欧美夫妻性生活| 国产精品麻豆视频| 激情国产一区二区| 欧美日韩免费观看一区二区三区| 久久久亚洲国产美女国产盗摄| 亚洲午夜激情网页| 97精品久久久久中文字幕| 精品国产伦一区二区三区免费| 一区二区三区视频在线看| 国产999精品久久久久久绿帽| 在线不卡一区二区| 一级女性全黄久久生活片免费| 春色校园综合激情亚洲| 欧美电影免费观看完整版| 午夜不卡在线视频| 日本精品免费观看高清观看| 国产精品女同一区二区三区| 国产一区二区剧情av在线| 欧美精品一二三四| 亚洲成在线观看| 欧美综合欧美视频| 亚洲一卡二卡三卡四卡五卡| 91福利视频在线| 亚洲人123区| 99精品视频免费在线观看| 国产精品久久久久三级| 成人av中文字幕| 最新国产の精品合集bt伙计| 成人精品在线视频观看| 日本一区二区免费在线| 国产白丝精品91爽爽久久| 久久九九影视网| 国产精品白丝jk黑袜喷水| 欧美国产综合一区二区| 亚洲国产你懂的| 欧美一区二区三区免费在线看| 蜜桃一区二区三区在线| 久久蜜臀中文字幕| 国产不卡视频在线播放| 亚洲欧洲国产日韩| 色老汉一区二区三区| 亚洲一区二区三区自拍| 欧美精品三级在线观看| 蜜臀久久99精品久久久久宅男 | 国产精品区一区二区三| av电影天堂一区二区在线| 亚洲精品视频一区| 欧美日韩一区中文字幕| 日本在线不卡一区| 久久久噜噜噜久久中文字幕色伊伊| 成人免费看的视频| 一区二区欧美精品| 欧美va亚洲va在线观看蝴蝶网| 国产精品一级片| 亚洲欧美色图小说| 日韩丝袜情趣美女图片| 国产九九视频一区二区三区| 亚洲欧美国产77777| 制服丝袜在线91| 成人做爰69片免费看网站| 亚洲尤物在线视频观看| 精品免费99久久| 色综合久久久久网| 日本午夜一区二区| 国产精品剧情在线亚洲| 欧美一区二区久久| 成人国产精品免费网站| 日韩电影免费一区| 一区在线中文字幕| 欧美大片日本大片免费观看| 97久久精品人人做人人爽| 麻豆成人久久精品二区三区小说| 亚洲天堂精品视频| 精品国产乱码久久久久久夜甘婷婷 | 成人精品在线视频观看| 日韩国产一区二| 亚洲视频一区二区免费在线观看| 欧美一区二区三区免费大片 | 欧美疯狂做受xxxx富婆| 国产精品小仙女| 日本三级亚洲精品| 亚洲欧美一区二区三区孕妇| 久久综合久久综合久久| 欧美日韩久久一区二区| 91在线观看成人| 懂色一区二区三区免费观看| 美女视频一区在线观看| 天堂一区二区在线| 亚洲欧美另类在线| 国产精品妹子av| 2022国产精品视频| 欧美一区二区在线播放| 欧美日韩电影一区| 色欧美片视频在线观看| 成人免费av资源| 狠狠v欧美v日韩v亚洲ⅴ| 奇米综合一区二区三区精品视频| 亚洲一区二区三区在线看| 亚洲精品自拍动漫在线| 中文字幕在线不卡视频| 中文字幕一区二区5566日韩| 欧美激情一区二区三区四区| 国产欧美日韩麻豆91| 国产欧美一区二区精品性色超碰| 久久一二三国产| 国产欧美精品一区二区色综合朱莉| 精品久久久久久亚洲综合网| 欧美不卡一二三| 精品理论电影在线| 精品国产电影一区二区| 久久综合九色综合欧美就去吻 | 一区二区三区四区亚洲| 亚洲免费观看视频| 亚洲一二三四区不卡| 日韩精品免费专区| 老司机免费视频一区二区 | 一区二区三区免费网站| 亚洲一区中文日韩| 日韩av电影免费观看高清完整版 | 在线观看日韩毛片| 欧美体内she精视频| 欧美理论在线播放| 精品国产乱码久久久久久夜甘婷婷| 久久婷婷国产综合精品青草 | 色94色欧美sute亚洲13| 欧美天堂一区二区三区| 91精品国产综合久久精品麻豆| 884aa四虎影成人精品一区| 精品久久久久久久久久久久包黑料| 2022国产精品视频| 国产精品第一页第二页第三页| 亚洲国产你懂的| 极品瑜伽女神91| 色综合色综合色综合| 3d动漫精品啪啪一区二区竹菊| 久久久一区二区| 亚洲欧美另类小说视频| 男女男精品视频| 成人激情校园春色| 欧美精品一二三| 石原莉奈在线亚洲三区| 老司机一区二区| 色呦呦国产精品| 欧美电影免费观看高清完整版在线| 久久网这里都是精品| 亚洲国产一区二区三区| 国产真实乱对白精彩久久| 色综合天天综合给合国产| 欧美精品一区二区三区蜜桃 | 高清beeg欧美| 在线精品视频一区二区| 久久久蜜桃精品| 午夜电影网一区| 91无套直看片红桃| www久久久久| 日韩精品视频网| 在线观看www91|