O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Debugging with GDB

Of the available tools for developing C applications, GDB (Gnu Debugger) is one of the more common. GDB is a command-line tool for C and C++, intended to help you find bugs in an application. It takes a while to learn how to make the most out of GDB, but if you do much C programming, doing so will pay off.

Programming for Easy Debugging

There are steps you can take to minimize the amount of debugging you have to do or to assist in the process when it does occur. The best practices include

  • Use lots of comments to explain the purpose of variables and specific code.

  • Avoid overly complex macros, functions, and statements.

  • Make explicit use of parentheses or otherwise be careful with operator precedence.

  • Make sure you're using =

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required