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.

The <strong>C++</strong>Builder IDE Explored: Projects and Forms<br />

As you can see, <strong>C++</strong>Builder does a good job of manag<strong>in</strong>g units for you. You have to be sure<br />

that you use the Include Unit Hdr option so that one unit can see the class declarations of<br />

other units, but for the most part, <strong>C++</strong>Builder frees you from hav<strong>in</strong>g to worry about your<br />

source files. Later, when your programm<strong>in</strong>g needs are more sophisticated, you’ll have to do<br />

a little more source file management, but at this stage of the game, <strong>C++</strong>Builder does most of<br />

the work for you.<br />

Now let’s take a moment to look at the different compil<strong>in</strong>g options available to you when<br />

you’re writ<strong>in</strong>g programs <strong>in</strong> <strong>C++</strong>Builder.<br />

Compil<strong>in</strong>g, Build<strong>in</strong>g, and L<strong>in</strong>k<strong>in</strong>g<br />

Each time you click the Run button, <strong>C++</strong>Builder compiles and l<strong>in</strong>ks your program. But it<br />

doesn’t necessarily compile every unit <strong>in</strong> the project. It only compiles any units that have<br />

changed s<strong>in</strong>ce the last compile. This feature saves you time because you don’t have to wait<br />

for the compiler to compile files that haven’t changed. <strong>C++</strong>Builder keeps track of which files<br />

have changed and which haven’t, so you don’t need to do anyth<strong>in</strong>g special to use this<br />

feature—it’s automatic.<br />

Most of the time you want to see <strong>in</strong> action the results of any changes you have made. In those<br />

cases you click the Run button and the program is compiled, l<strong>in</strong>ked, and executed.<br />

Sometimes, however, you don’t want to run the program. For <strong>in</strong>stance, you might want to<br />

compile the program just to see whether there are any errors. <strong>C++</strong>Builder has three menu<br />

items <strong>in</strong> addition to Run that allow you to control the compile/l<strong>in</strong>k process. If you choose<br />

the Project menu item on the ma<strong>in</strong> menu, you will see three menu items called Compile Unit,<br />

Make, and Build All. Let’s take these <strong>in</strong> order of simplest to most complex (from the<br />

compiler’s perspective).<br />

The Compile Unit option is one I really like. This feature causes <strong>C++</strong>Builder to compile the<br />

current unit <strong>in</strong> the Code Editor and report any errors and warn<strong>in</strong>gs. This is the fastest way<br />

to check for errors <strong>in</strong> your code. <strong>C++</strong>Builder only compiles the file—it does not perform a<br />

l<strong>in</strong>k. The purpose of the Compile Unit option is to check your code for syntax errors as<br />

quickly as possible. Because the l<strong>in</strong>k phase takes extra time, the Compile Unit option skips<br />

that step.<br />

The Make option compiles any units that have changed s<strong>in</strong>ce the last compile just as the<br />

Compile Unit options does, but it also l<strong>in</strong>ks the entire project. Naturally, this takes slightly<br />

longer than the Compile Unit option. Use the Make option when you want to be sure the<br />

program will compile and l<strong>in</strong>k but you don’t want to run the program.<br />

183<br />

6

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

Saved successfully!

Ooh no, something went wrong!