Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A couple of my own, from spending too many nights debugging stuff that the compiler or runtime environment could have warned me about if I'd used it properly:</p> <ul> <li>If you're doing anything with pointers in C++, assert() them wherever suitable. In fact, assert()ing invariants is generally a good idea and can cut the debugging time on that one obscure bug from weeks to minutes. Just remember to turn them off in the release build. Oh, and don't put anything in there that has side effects, otherwise you'll be debugging your release build for a little while. Don't ask me how I found out that one</li> <li>In a similar vein, BOOST_STATIC_ASSERT can be extremely helpful in checking for discrepancies you can check at compile time</li> <li>Memory debuggers like <a href="http://www.ibm.com/developerworks/rational/products/purifyplus/" rel="nofollow noreferrer">PurifyPlus</a> or <a href="http://valgrind.org/" rel="nofollow noreferrer">valgrind</a> are excellent time-saving devices and should be on every developer's machine</li> <li>Learn how to use the debugger properly so you can harness its full power instead of just using it as a device that allows you to single-step through your code</li> <li>If you're really stuck, explain the problem and the code to a colleague</li> <li>For C++, a tool like <a href="http://www.gimpel.com/" rel="nofollow noreferrer">FlexeLint/PC-Lint</a> can help pinpoint a lot of hard-to-find stuff once you configured it properly. You'll have to invest the time to configure it otherwise you'll drown in warnings</li> <li>If you're writing C++ and you're using the standard containers, write code that uses iterators and let the debug version of the runtime (or a debug STL) catch your off-by-one errors. If you use indices to reference elements in, say, a std::vector&lt;> you'll have to find those yourself</li> <li>Run the code through different compilers if you can and pay heed to the warnings each one of them produces. However make sure that they're at similar levels of language compatibility (no point in running modern C++ code through MS VC++ 6) otherwise you'll end up chasing problems that aren't really there.</li> </ul> <p>Ideally, you should try to catch problems before you need to fire up the debugger - anything you can tweak such that it creates a compilation error is much easier to fix compared to tracking it down in the debugger and then fixing it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload