Changing Compiler Options

Up to this point, you have used PWB's default build options for all the examples. These options are sufficient for many cases, but occasionally you will want to adjust them.

Suppose you decide to optimize the COUNT program for size to get the smallest code possible regardless of the execution speed. Ordinarily, you don't consider optimizations until your code has stabilized and you are ready to try a release build. (A release build is normally a build with optimizations turned on and debugging information turned off.)

·To specify a release build:

1.From the Options menu, choose Build Options.

PWB displays the Build Options dialog box.

2.Choose Use Release Options.

3.Choose OK to accept your choice.

When you specify a release build, PWB does not change your debug options. For more information on global options, debug options, and release options, see “Setting Build Options”.

Now that you have chosen a release build, you can set specific options that PWB uses to create a release version of the program.

·To change compiler options to optimize for space:

1.From the Language Options cascaded menu on the Options menu, choose C Compiler Options.

The C Compiler Options dialog box displays the following options that are common to both the release and debug builds (Global Options):

Memory model

Processor (type of CPU)

Calling convention

Warning level

At the bottom of the dialog box is a panel that shows options that are specific to the current type of build. In this case, release options are being used. The default settings for a build were determined when you chose the project template.

Note:

You can choose the Debug Options button to view and set the options for debug builds. However, this does not change the type of build that is performed when you build the project. To set the type of build, choose Build Options from the Options menu. 1.Choose Optimizations.

PWB displays a dialog box in which you can specify release optimizations.

Turn on the Optimize for Space option. PWB automatically turns off the Optimize for Time option.Choose OK to return to the C Compiler Options dialog box.Choose OK to set the new options that you have selected.

The procedure you have just completed causes PWB to build an executable file that is optimized for space the next time you choose Build or Rebuild from the Project menu.