12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Us<strong>in</strong>g the Debugger<br />

■ Ord<strong>in</strong>arily you cannot use Trace Into with <strong>in</strong>l<strong>in</strong>e functions. To be able to trace<br />

<strong>in</strong>to <strong>in</strong>l<strong>in</strong>e functions, you can turn on the Disable Inl<strong>in</strong>e Expansions option. Turn<br />

off the option aga<strong>in</strong> before your f<strong>in</strong>al build.<br />

■ To <strong>in</strong>spect the class that the debugger is currently stopped <strong>in</strong>, choose Run | Inspect<br />

from the ma<strong>in</strong> menu and enter this <strong>in</strong> the Expression field.<br />

■ Use MessageBeep(-1) as an audible <strong>in</strong>dicator that a certa<strong>in</strong> po<strong>in</strong>t <strong>in</strong> your program<br />

has been reached. This W<strong>in</strong>dows API function beeps the PC speaker when called<br />

with a parameter of -1.<br />

■ You can stop an errant debuggee by choos<strong>in</strong>g Run | Program Reset from the ma<strong>in</strong><br />

menu or by press<strong>in</strong>g Ctrl+F2.<br />

■ Use temporary variables to break down long equations or cha<strong>in</strong>ed function calls so<br />

that you can exam<strong>in</strong>e the results <strong>in</strong> more manageable pieces.<br />

■ Use the MessageBox() function to display program trac<strong>in</strong>g <strong>in</strong>formation.<br />

Summary<br />

Debugg<strong>in</strong>g is a never-end<strong>in</strong>g task. Debugg<strong>in</strong>g means more than just track<strong>in</strong>g down a bug <strong>in</strong><br />

your program. Savvy programmers learn to use the debugger from the outset of a new project.<br />

The debugger is a development tool as well as a bug-f<strong>in</strong>d<strong>in</strong>g tool. After today, you should at<br />

least have a basic understand<strong>in</strong>g of how to use the debugger. You will still have to spend a lot<br />

of time actually us<strong>in</strong>g the debugger before you are proficient at it, but you’ve now got a place<br />

to start.<br />

Workshop<br />

The Workshop conta<strong>in</strong>s quiz questions to help you solidify your understand<strong>in</strong>g of the<br />

material covered and exercises to provide you with experience <strong>in</strong> us<strong>in</strong>g what you have learned.<br />

You can f<strong>in</strong>d answers to the quiz questions <strong>in</strong> Appendix A, “Answers to Quiz Questions.”<br />

Q&A<br />

Q My program used to run at regular speed when I ran it from the IDE. Now it’s<br />

as slow as molasses <strong>in</strong> January. Why is that?<br />

A More than likely you’ve got either a large number of breakpo<strong>in</strong>ts that you have<br />

disabled and forgotten about, or one or more conditional breakpo<strong>in</strong>ts <strong>in</strong> your code.<br />

Go to the breakpo<strong>in</strong>t list and delete any breakpo<strong>in</strong>ts you are not currently us<strong>in</strong>g.<br />

Also, be sure you do not have a lot of variables listed <strong>in</strong> the Watch List.<br />

423<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!