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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NOTE<br />

TIP<br />

More on Projects<br />

To avoid the problem with register variables, you can do one of two<br />

th<strong>in</strong>gs. The first is to turn off the Automatic Register Variables option<br />

while debugg<strong>in</strong>g your application. Turn it back on aga<strong>in</strong> when you are<br />

done debugg<strong>in</strong>g and before your product ships.<br />

The other th<strong>in</strong>g you can do is to declare a local variable with the<br />

volatile keyword:<br />

volatile <strong>in</strong>t x;<br />

This will prevent the compiler from optimiz<strong>in</strong>g the variable, thereby<br />

mak<strong>in</strong>g it available for <strong>in</strong>spection.<br />

If you turn off the Automatic Register Variables option, you can still force the compiler to<br />

treat a particular variable as a register variable by declar<strong>in</strong>g it with the register keyword.<br />

Here’s an example:<br />

register <strong>in</strong>t x = 20;<br />

Disable Inl<strong>in</strong>e Expansions<br />

The Disable Inl<strong>in</strong>e Expansions option controls how <strong>in</strong>l<strong>in</strong>e functions are handled by the<br />

compiler. By default, <strong>in</strong>l<strong>in</strong>e functions are expanded <strong>in</strong>l<strong>in</strong>e (placed <strong>in</strong> the code where<br />

necessary) as you would expect. If you turn on this option, thereby disabl<strong>in</strong>g <strong>in</strong>l<strong>in</strong>e expansion,<br />

<strong>in</strong>l<strong>in</strong>e functions will be treated as regular functions rather than as <strong>in</strong>l<strong>in</strong>e functions. Use of this<br />

option is rare, but you may need to use it on occasion when debugg<strong>in</strong>g certa<strong>in</strong> <strong>in</strong>l<strong>in</strong>e<br />

functions.<br />

If you change any of the options on the <strong>C++</strong> page, you should do a<br />

Build All immediately follow<strong>in</strong>g. This will ensure that all modules are<br />

built us<strong>in</strong>g the same compiler sett<strong>in</strong>gs.<br />

Pre-compiled Headers<br />

Note the Pre-compiled Headers section on the <strong>C++</strong> page of the Project Options dialog box.<br />

A pre-compiled header is essentially an image of the symbol table for a project stored on disk.<br />

The first time you build your program, <strong>C++</strong>Builder creates the pre-compiled header. On<br />

subsequent makes, <strong>C++</strong>Builder can load the pre-compiled header from disk, which is much<br />

faster than compil<strong>in</strong>g the headers for each build. In addition, you can opt to cache the precompiled<br />

header <strong>in</strong> memory. This <strong>in</strong>creases compile speed even more because the precompiled<br />

header can be held <strong>in</strong> memory rather than be<strong>in</strong>g loaded from disk when needed.<br />

369<br />

10

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

Saved successfully!

Ooh no, something went wrong!