TOPIC 13.2.1
Working With Projects


Since your programs now may consist of more than one file, having a way to automatically identify those that need to be recompiled and linked would be ideal. Projects or workspaces do just that and more.

Projects allow you to specify the files that belong to the program. Once a project or workspace is set up the compiler knows how to build the program using all of the sources files specified in the project.

To better understand how a project works, suppose you have a program that consists of a main source file, PROGRAM.CPP, a support file, PROMPTS.CPP, which contains functions referenced from the main file, and PROMPTS.H, which contains the function definitions for the functions in PROMPTS.CPP.

Once the two cpp files are added to the project the compiler is able to create object files and create the executable file. Now suppose that changes had to be made to the PROMPTS.CPP file. The next time the compiler creates the executable file, it does not have to recompile the PROGRAM.CPP file, which could be very large and could take some time.

Now consider adding another support file to the program. The PROGRAM.CPP file would have to be changed to include the new support file's .h file, and new cpp, and .h files would have to be created for the support file. After the new support file is added to the project, the program can be compile. This time the PROMPTS.CPP file does not have to be recompiled, which could also be very large and could take some time.