您好,欢迎光临本网站![请登录][注册会员]  
文件名称: C++ Hackers Guide
  所属分类: C++
  开发工具:
  文件大小: 2mb
  下载次数: 0
  上传时间: 2010-03-15
  提 供 者: zlten*****
 详细说明: Table of Contents Real World Hacks................................................................................................9 Hack 1: Make Code Disappear..........................................................................10 Hack 2: Let Someone Else Write It...................................................................12 Hack 3: Use the const Keyword Frequently For Maximum Protection.............12 Hack 4: Turn large parameter lists into structures..........................................14 Hack 5: Defining Bits .........................................................................................16 Hack 6: Use Bit fields Carefully........................................................................18 Hack 7: Documenting bitmapped variables......................................................19 Hack 8: Creating a class which can not be copied............................................21 Hack 9: Creating Self-registering Classes.........................................................22 Hack 10: Decouple the Interface and the Implementation...............................25 Hack 11: Learning From The Linux Kernel List Functions...............................27 Hack 12: Eliminate Side Effects........................................................................29 Hack 13: Don't Put Assignment Statements Inside Any Other Statements......30 Hack 14: Use const Instead of #define When Possible.....................................31 Hack 15: If You Must Use #define Put Parenthesis Around The Value.............32 Hack 16: Use inline Functions Instead of Parameterized Macros Whenever Possible........................................................................................................33 Hack 17: If You Must Use Parameterized Macros Put Parenthesis Around The arguments....................................................................................................34 Hack 18: Don't Write Ambiguous Code.............................................................34 Hack 19: Don't Be Clever With the Precedence Rules......................................35 Hack 20: Include Your Own Header File...........................................................36 Hack 21: Synchronize Header and Code File Names.......................................37 Hack 22: Never Trust User Input......................................................................38 Hack 23: Don't use gets.....................................................................................40 Hack 24: Flush Debugging................................................................................41 Hack 25: Protect array accesses with assert....................................................42 Hack 26: Use a Template to Create Safe Arrays...............................................45 Hack 27: When Doing Nothing, Be Obvious About It........................................46 Hack 28: End Every Case with break or /* Fall Through */...............................47 Hack 29: A Simple assert Statements For Impossible Conditions....................47 Hack 30: Always Check for The Impossible Cases In switches.........................48 Hack 31: Create Opaque Types (Handles) Which can be Checked at Compile Time.............................................................................................................49 Hack 32: Using sizeof When Zeroing Out Arrays..............................................51 Hack 33: Use sizeof(var) Instead of sizeof(type) in memset Calls....................51 Hack 34: Zero Out Pointers to Avoid Reuse......................................................53 Hack 35: Use strncpy Instead of strcpy To Avoid Buffer Overflows.................54 Hack 36: Use strncat instead of strcat for safety..............................................55 Hack 37: Use snprintf To Create Strings..........................................................56 Hack 38: Don't Design in Artificial Limits.........................................................57 Hack 39: Always Check for Self Assignment.....................................................58 Hack 40: Use Sentinels to Protect the Integrity of Your Classes......................60 Hack 41: Solve Memory Problems with valgrind..............................................61 Hack 42: Finding Uninitialized Variables..........................................................63 Hack 29: Valgrind Pronunciation.......................................................................65 Hack 43: Locating Pointer problems ElectricFence..........................................65 Hack 44: Dealing with Complex Function and Pointer Declarations................65 Hack 45: Create Text Files Instead of Binary Ones Whenever Feasible...........67 Hack 46: Use Magic Strings to Identify File Types...........................................69 Hack 47: Use Magic Numbers for Binary Files.................................................69 Hack 48: Automatic Byte Ordering Through Magic Numbers..........................70 Hack 49: Writing Portable Binary Files.............................................................71 Hack 50: Make You Binary Files Extensible......................................................72 Hack 51: Use magic numbers to protect binary file records............................74 Hack 52: Know When to Use _exit....................................................................76 Hack 53: Mark temporary debugging messages with a special set of characters....................................................................................................78 Hack 54: Use the Editor to Analyze Log Output...............................................78 Hack 55: Flexible Logging.................................................................................79 Hack 56: Turn Debugging On and Off With a Signal........................................81 Hack 57: Use a Signal File to Turn On and Off Debugging..............................82 Hack 58: Starting the Debugger Automatically Upon Error.............................82 Hack 59: Making assert Failures Start the Debugger.......................................88 Hack 60: Stopping the Program at the Right Place..........................................90 Hack 61: Creating Headings within Comment..................................................92 Hack 62: Emphasizing words within a paragraph............................................93 Hack 63: Putting Drawings In Comments.........................................................93 Hack 64: Providing User Documentation..........................................................94 Hack 65: Documenting the API.........................................................................96 Hack 66: Use the Linux Cross Reference to Navigate Large Coding Projects. 99 Hack 67: Using the Pre-processor to Generate Name Lists............................103 Hack 68: Creating Word Lists Automatically..................................................104 Hack 69: Preventing Double Inclusion of Header Files..................................105 Hack 70: Enclose Multiple Line Macros In do/while.......................................105 Hack 71: Use #if 0 to Remove Code...............................................................107 Hack 72: Use #ifndef QQQ to Identify Temporary Code.................................107 Hack 73: Use #ifdef on the Function Not on the Function Call to Eliminate Excess #ifdefs............................................................................................108 Hack 74: Create Code to Help Eliminate #ifdef Statements From Function Bodies........................................................................................................109 Hack 75: Don't Use any “Well Known” Speedups Without Verification..........112 Hack 76: Use gmake -j to speed up compilation on dual processor machines ................................................................................................................... 115 Hack 77: Avoid Recompiling by Using ccache................................................117 Hack 78: Using ccache Without Changing All Your Makefiles........................118 Hack 79: Distribute the Workload With distcc................................................119 Hack 80: Don't Optimize Unless You Really Need to .....................................120 Hack 81: Use the Profiler to Locate Places to Optimize ................................120 Hack 82: Avoid the Formatted Output Functions............................................122 Hack 83: Use ++x Instead of x++ Because It's Faster...................................123 Hack 84: Optimize I/O by Using the C I/O API Instead of the C++ One........124 Hack 85: Use a Local Cache to Avoid Recomputing the Same Result............126 Hack 86: Use a Custom new/delete to Speed Dynamic Storage Allocation....128 Anti-Hack 87: Creating a Customized new / delete Unnecessarily.................129 Anti-Hack 88: Using shift to multiple or divide by powers of 2......................130 Hack 89: Use static inline Instead of inline To Save Space............................131 Hack 90: Use double Instead of Float Faster Operations When You Don't Have A Floating Point Processor.........................................................................132 Hack 91: Tell the Compiler to Break the Standard and Force it To Treat float as float When Doing Arithmetic.....................................................................133 Hack 92: Fixed point arithmetic......................................................................134 Hack 93: Verify Optimized Code Against the Unoptimized Version................138 Case Study: Optimizing bits_to_bytes.............................................................139 Hack 94: Designated Structure Initializers....................................................144 Hack 95: Checking printf style Arguments Lists.............................................145 Hack 96: Packing structures...........................................................................146 Hack 97: Creating Functions Who's Return Shouldn't Be Ignored.................146 Hack 98: Creating Functions Which Never Return.........................................147 Hack 99: Using the GCC Heap Memory Checking Functions to Locate Errors ...................................................................................................................149 Hack 100: Tracing Memory Usage..................................................................150 Hack 101: Generating a Backtrace.................................................................152 Anti-Hack 102: Using “#define extern” for Variable Declarations.................156 Anti-Hack 103: Use , (comma) to join statements...........................................158 Anti-Hack 104: if (strcmp(a,b)) .......................................................................159 Anti-Hack 105: if (ptr) ....................................................................................161 Anti-Hack 106: The “while ((ch = getch()) != EOF)” Hack.............................161 Anti-Hack 107: Using #define to Augment the C++ Syntax..........................163 Anti-Hack 108: Using BEGIN and END Instead of { and }.............................163 Anti-Hack 109: Variable Argument Lists.........................................................164 Anti-Hack 110: Opaque Handles.....................................................................166 Anti-Hack 111: Microsoft (Hungarian) Notation.............................................166 Hack 112: Always Verify the Hardware Specification.....................................170 Hack 113: Use Portable Types Which Specify Exactly How Wide Your Integers Are..............................................................................................................171 Hack 114: Verify Structure Sizes....................................................................172 Hack 115: Verify Offsets When Defining the Hardware Interface..................174 Hack 116: Pack Structures To Eliminate Hidden Padding..............................174 Hack 117: Understand What the Keyword volatile Does and How to Use It.. 175 Hack 118: Understand What the Optimizer Can Do To You............................177 Hack 119: In Embedded Programs, Try To Handle Errors Without Stopping180 Hack 120: Detecting Starvation......................................................................182 Hack 121: Turning on Syntax Coloring...........................................................185 Hack 122: Using Vim's internal make system.................................................185 Hack 123: Automatically Indenting Code........................................................188 Hack 124: Indenting Existing Blocks of Code.................................................188 Hack 125: Use tags to Navigate the Code......................................................190 Hack 126: You Need to Find the Location of Procedure for Which You Only Know Part of the Name..............................................................................194 Hack 127: Use :vimgrep to Search for Variables or Functions.......................196 Hack 128: Viewing the Logic of Large Functions...........................................197 Hack 129: View Logfiles with Vim...................................................................199 Hack 130: Flipping a Variable Between 1 and 2.............................................201 Hack 131: Swapping Two Numbers Without a Temporary.............................202 Hack 132: Reversing the Words In a String Without a Temporary.................204 Hack 133: Implementing a Double Linked List with a Single Pointer............206 Hack 134: Accessing Shared Memory Without a Lock...................................207 Hack 135: Answering the Object Oriented Challenge....................................209 Appendix A: Hacker Quotes................................................................................211 Grace Hopper..................................................................................................211 Linux Torvals...................................................................................................212 Appendix B: You Know You're a Hacker If...........................................................214 Appendix C: Hacking Sins...................................................................................216 Using the letters O, l, I as variable names......................................................216 Not Sharing Your Work....................................................................................216 No Comments..................................................................................................216 IncOnsisTencY.................................................................................................216 Duplicating Code (Programming by Cut and Paste)........................................217 Appendix D: Open Source Tools For Hackers.....................................................218 ctags – Function Indexing System...................................................................218 doxygen...........................................................................................................218 FlawFinder......................................................................................................218 gcc – The GNU C and C++ compiler suite......................................................218 lxr218 Perl (for perldoc and related tools) – Documentation System........................219 valgrind (memory checking tools)...................................................................219 Vim (Vi Improved)............................................................................................219 Appendix E: Safe Design Patterns.......................................................................220 Appendix F: Creative Commons License.............................................................225 License.........................................................................................................225 Creative Commons Notice...........................................................................230 ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: C++ Hackers Guide 技巧
 输入关键字,在本站1000多万海量源码库中尽情搜索: