7. Configuring IDE Options



This chapter discusses the many options available in CodeWarrior's Preferences and Project Settings dialogs.


Configuring IDE Options Overview

You can control many options in CodeWarrior. The CodeWarrior IDE has a single dialog for handling options. It is known as the Settings dialog. This chapter discusses all the options available in the Settings dialog.

To set options that are global or specific to a project in the BeIDE, you choose the Settings command from the Window Menu. Use the Apply To popup menu to specify whether the option settings apply to New Projects, Current Projects, or the Message window.

In each case, the many options are organized into a series of panels devoted to a particular topic. For example, one panel controls the font and tab settings in the editor. Another panel controls the target for which you are compiling code.

The topics in this chapter include:


Settings Dialogs Guided Tour

The various options available to you for configuring CodeWarrior settings are found on the Window Menu, using the Settings command.

The topics in this section are:

The Settings dialog includes an Apply To pop-up menu which enables you to choose whether the changes you make apply to New Projects, or the Current Project.

  • New Project
  • By default, if no project is open, the New Project option is selected automatically. All changes made will then be used as the default setting for all new projects created.

  • Current Project
  • When a project is already open, the Current Project option is enabled. All changes made in the option panels apply only to the current project.


    Settings Panels

    To see the settings dialog where you configure your CodeWarrior Project Settings, choose the Settings command from the Window Menu. You see a dialog such as that shown in Figure 7.1. The actual panels available to you will vary depending upon the CodeWarrior product you are using.

    A typical Project Settings window for BeOS development on PowerPC, for example, allows you to configure the C/C++ Warnings, PPC Project Panel, Access Paths, Target, PPC Processor, PPC Disassembler, PPC Linker, and many more. To select one of these to configure, click the panel name that you want to see.

    By using the disclosure triangles, you can collapse or expand the list of available settings panels to choose from.

    To view the Editor settings panel, as shown in Figure 7.1, click the Editor list option after using the disclosure triangle to expand the Editor Category.

    Figure 7.1 Settings choices


    Figure 7.2 shows that when a given Settings panel is selected, the dialog fills wth controls and fields that you can configure to your liking.

    To set global preferences, select one of the panels listed below the Editor or General headings. The global preferences panels include Editor Options, Font and Size Settings, Syntax Styling, Build Extras, Key Bindings and Editor Settings.



    Settings Panel Buttons


    Factory Settings button

    When you click the Factory Settings button in a Settings dialog, you are telling CodeWarrior to restore the default settings that CodeWarrior shipped with. You may continue to make changes. When you are finished, click the Save button to save your changes, then click the window's close box to close the dialog.


    Revert Panel button

    When you click the Revert Panel button in the Settings dialog, you are telling CodeWarrior to reset the panel to the state in which it was opened. You may continue to make changes. When you are finished, click the window's close box to close the dialog.


    Cancel button


    When you click the Cancel button in the Settings dialogs, you are telling CodeWarrior to discard any changes you have made and close the dialog.


    Save button

    When you click the Save button in the Settings dialog, you are telling CodeWarrior to save any changes you have made. You may continue to make changes. When you are finished, click the window's close box to close the dialog.


    Editor Settings Panels

    To configure any of these panels, click the appropriate name in the list to display the associated panel.

    The panels discussed in this section include:


    Editor

    You can configure the CodeWarrior Editor to conform to the way you work. This section tells how to configure the Editor's behavior to make your text editing chores easier. The Editor settings panel is shown in Figure 7.2.

    Figure 7.2 Editor settings Panel


    When Opening a Text Document

    Specify which font settings to use when displaying an opened text document. This is a global setting that applies to all documents opened by CodeWarrior.


    Use document font settings

    When `Use document font settings' is enabled, the font settings are taken from the document.


    Use project font settings

    When `Use project font settings' is enabled, the font settings are taken from the project.


    Use `New Project' font settings

    When `Use `New Project' font settings' is enabled, the font settings are taken from the'New Project' settings panel .


    Font

    Use the settings panel shown in Figure 7.3 to change the Fonts and Size settings. If you change the font with this panel for each file in your project when the file is the active Editor window, you can have the font remembered each time the file is opened.

    Figure 7.3 Fonts settings panel


    This preference panel sets the font and tab information for the file chosen in the Apply to pop-up menu..

    To change the font and size settings for a file, make it the active Editor window, then open this settings panel and make your changes. As long as you have write permissions on the file, your changes will be remembered.

    Enable Auto Indent if you want the editor to automatically indent text on a new line to match up with the text on the previous line.

    Tab Size is the number of spaces CodeWarrior inserts to make up a `tab' using the Tab key.




    Syntax Styling

    The Syntax Styling settings panel provides four Syntax Styling settings you can use to customize Editor windows.

    To enable Syntax Styling, enable the Use Syntax Styling checkbox in the top left corner of the settings panel, as shown in Figure 7.4.

    Figure 7.4 Syntax Styling settings panel



    Table 7.1 describes each element of text CodeWarrior highlights in color.

    Table 7.1 Syntax Styling highlights

    Element
    Description
    Text
    Anything that's not a comment, keyword, or custom keyword, such as literal values, variable names, routine names, and type names. By default, characters are black.
    Comments
    Code comments. In C or C++, a comment is text enclosed by /* and */ or text from // to the end of the line. By default, characters are red.
    Keywords
    The language's keywords. It does not include any macros, types, or variables that you or the system interface files define. By default, characters are blue.
    Strings
    All strings. By default, characters are gray.


    Changing syntax styling

    In the Syntax Styling preference panel, select any type of text you want to change. An outline will appear around the current selection. In Figure 7.4, the type of text chosen is Text.

    The CodeWarrior BeIDE can use different fonts and sizes to display different types of text. Use the Font and Size popups to specify the font and size for the current type of text. The next time you view a text file, CodeWarrior uses the font and size settings to display that type of text.


    NOTE:

    Bitmapped fonts are no longer supported by the BeOS.

    CodeWarrior also uses different colors for each type of text. To change these colors, choose from the color palette near the bottom of the panel, or enter the values diretly in the Red, Green, and Blue fields. Color values must range between 0 and 255. The next time you view a text file, CodeWarrior uses the new color.


    TIP:

    The CodeWarrior IDE now supports the dragging of colors from third party applications (such as Rocolor), so that you can now use any custom color in the IDE.

    A sample of the current settings for the currently selected type of text is displayed at the bottom of the Syntax Styling panel.


    General Settings Panels

    To configure any of these panels, click the appropriate name in the list to display the associated panel.

    The panels discussed in this section include:


    Build Extras

    This panel currently only contains the Concurrent Compiles option.


    Concurrent Compiles

    Choose from the Concurrent Compiles popup the number of concurrent compiles the BeIDE uses to compile the project.


    Key Bindings

    You can customize command keys for menu, keyboard, and editor commands in the CodeWarrior IDE. You can attach or "bind" almost any key to any command. This feature allows you to change the keys that activate many commands in the CodeWarrior IDE to those that you find convenient for your working style.

    For example, if you use a Mac OS compatible keyboard, you may wish to change the key equivalent for Save from Command-S to Command-Option-S. You could change this using the key bindings feature.

    You control key bindings in the Key Bindings settings panel shown in Figure 7.5. You can set the key bindings for menu commands, source code editor actions, and other miscellaneous actions. You can also specify special prefix keys.

    Figure 7.5 Key Bindings panel


    The topics discussed in this section are:


    Restrictions for choosing key bindings

    When you are customizing key bindings, you need to be aware of some restrictions for keys that can and can not be used. These restrictions are listed here.

    The Return and Tab keys require at least one of the following: Control, Command, or Shift on Mac OS-compatible keyboards keyboards, or the Control or Shift key on Windows-compatible keyboards. This restriction does not apply for the second key of a two-key sequence.

    The Escape and Space keys are always invalid for key bindings.

    The Alt key is not valid for use in key bindings (Windows compatible keyboards only), and the Command-period (Command-.) key combination is invalid for any binding (Mac OS compatible keyboards only).Function keys and the Clear key are valid for creating key bindings.


    What is a prefix key?

    Prefix keys allow you to create multiple-keystroke command keys, such as those used in the Emacs text editor available on many different computer platforms. For example, the key sequence in Emacs to save a file is Control-X followed by Control-S.

    To emulate this Emacs key binding in the CodeWarrior IDE, first set one of the Prefix Keys to be Control-X, and then set the command key for the Save menu command to Control-X Control-S.

    You can also adjust the maximum time to wait for a key press after a Prefix Key is entered. To learn how to do this, refer to "Setting the Prefix Key Timeout."


    Setting the Prefix Key Timeout

    The Prefix Key Timeout field sets how long the IDE waits for the second key after a prefix key is pressed. Larger values mean that the IDE will wait longer for the second key to be pressed.

    This value is in "ticks" which are the same as 1/60th of a second (16.67 millseconds). Legal values are in the range of 1 to 999. The default is 120.


    Modifying key bindings

    When you select the Key Bindings item from the list of IDE preference panels, you see the Key Bindings panel shown in Figure 7.5.

    To change the key that will activate a given IDE operation, you must first select the operation you wish to modify. To do this, click the disclosure triangle next to the Command category to show the individual operations.

    To change a key binding, double-click the command you wish to change, or select it and press the Return key.

    When you do, the dialog box shown in Figure 7.6 appears.

    Once you see this dialog, press the key combination that you want to use for the command. For example, if you want to make the command key Control-8, you would press the Control key and the 8 key at the same time.

    You may also specify an alternate key that can be used for the command. To create an additional command key, click on the Alternate rectangle so that it is selected. Then, hold down the keys that you want to use for the command. If you specify an alternate command key, either key can be used to execute the command.

    The only exception to the alternate key feature is prefix keys. You cannot specify an alternate key for any prefix key.

    If you wish to clear the Primary or Alternate command keys, click the Clear button to the right of the appropriate field.

    Figure 7.6 Modify Key Binding Dialog Box


    When you are finished changing key bindings, click the Apply button to dismiss the dialog box, saving your changes. If you do not wish to save your changes, click the Cancel button.


    Exporting key bindings

    If you wish to save your key bindings in a file so that you can later import them into the IDE at another time, you use the Export button. When you click this button, a standard file dialog box appears, as shown in Figure 7.7. Navigate to the place on your hard disk where you want to save the key bindings file, and click Save.

    Figure 7.7 Export Key Bindings Dialog Box



    Importing key bindings

    If you wish to import saved key bindings from a previously-exported file, you use the Import button. Use the standard file dialog to locate and open the key bindings file.


    Editor bindings

    Table 7.2 lists the default key equivalents for each command in the editor, and describes what each command does. To learn more about text navigation features of the Editor, refer to "Navigating in Text."

    Table 7.2 Editor key bindings

    Command
    Default Key Binding
    Description
    Move character left
    Left Arrow
    Moves the text insertion point one character to the left.
    Move character right
    Right Arrow
    Moves the text insertion point one character to the right.
    Tab between characters
    Tab
    Moves the text insertion point the distance specified in the Tab Size field (Font and Size Settings)


    Editor Settings

    These are the settings available in the Editor Settings panel, as shown in Figure 7.8.

    Figure 7.8 Editor Settings panel



    Balance While Typing

    When the Balance While Typing option is enabled, CodeWarrior checks for balanced parentheses, brackets, and braces as you type.

    When you type a right parenthesis, bracket, or brace, the editor searches for the left counterpart. If the editor finds it, the editor highlights it for a specified length of time called the Flashing Delay (scrolling to bring it into view, if necessary) and then resumes (scrolling back to where you were, if necessary). If the editor doesn't find a match, it beeps.

    By default, the Balance While Typing option is on.

    You will want to learn about the Flashing Delay parameter to get the most flexibility from this feature.


    TIP:

    If you want to check for balanced punctuation without flashing it, set the Flashing Delay to 0.

    Relaxed C Popup Parsing

    Enable this option if you use K&R style coding conventions in your source code to better allow the CodeWarrior IDE to recognize and display function names in the Routine pop-up menu. Disable this option if you use non-standard macros that can interfere with K&R styled code.

    For further information on the Routine pop-up menu, see "Routine Pop-up Menu."


    NOTE:

    Some macro functions will not be recognized when this option is enabled. If you encounter problems with routine names not displaying, disable this option and try again.

    Flashing Delay

    The Flashing Delay is the amount of time the CodeWarrior editor displays and highlights an item. It is measured in 1\xda 60 of a second.


    Remember Selection Position

    This option tells CodeWarrior to remember what text was scrolled into view, and the location of the insertion point or selection when a file is closed. Turn this option off if you always want the editor to go to the top of the file when it opens a window. This feature requires that your files be writable.


    Sort Function Popup

    Enable this option if you want the Routine Pop-up Menu in the Editor window to always be sorted by default. To learn more about this feature, see "Routine Pop-up Menu."


    Color Settings

    There are two options in the Color Settings region of the Editor Settings panel.


    Hilite

    To change the hilite color, click the Hilite box and choose a color from the palette window below.


    Background

    To change the background color, click the Background box and choose a color from the palette window below.


    Project Settings Panels

    You can change many different settings to configure CodeWarrior to build your project the way you want. This section discusses the changes you can make to Project Settings specific to your project.

    The topics in this section include:


    Access Paths

    To define additional access paths for CodeWarrior to search while compiling and linking your project, use the Access Paths panel, shown in Figure 7.9.

    If a folder icon appears beside the name of a folder in either the Project Path pane, or the System Path pane, CodeWarrior performs a recursive search on the path (that is, CodeWarrior searches that folder and all the folders within it).

    Figure 7.9 Access Paths settings panel


    CodeWarrior will only find a project's files in the access paths listed in this panel. If a project file is not in one of the access paths then you must add the access path to the panel. The types of paths you can specify include:

    Absolute Path means that all the folders that lead to your project folder, including the hard disk, will be incorporated in the Access Path. You need to update an absolute access path if you move a project to another system, or rename the hard drive, or rename the folder that contains the project.


       /boot/develop/projects/BeBounce/
  • Project relative
  • Project Relative Path means that the folders that lead to your folder, in relation to the folder that contains the current project, will be incorporated in the Access Path. You do not need to update relative access paths if you move a project, as long as the hierarchy of the relative path is the same. However, you cannot create a relative path to a folder on a different hard disk than where your project file resides.


       ../projects/BeBounce/
  • IDE relative
  • IDE Relative means that the folder leading to your folder, in relation to the folder that contains CodeWarrior, will be incorporated in the Access Path. You do not need to update relative access paths if you move a project, as long as the hierarchy of the relative path is the same. However, you cannot create a relative path to a folder on different hard disk than where your project file resides.


       /projects/BeBounce/

    If your project's files or libraries are not in either of the default access paths, CodeWarrior will not find them when compiling, linking, or running your project. You must add their access path to tell the environment where to look.


    Treat #include <> as #include ""

    To search for system header or interface files in the same way as user header files, turn on this option.


    Add Default

    CodeWarrior lets you add the default path for the Project Include Path Pane or System Include Path Pane after you have deleted the default path. To add the default path to the access path pane you are working with, click the Add Default button. CodeWarrior adds the default path back into the relevant path pane.


    Add

    To add a new access path, first select the System Include Path Pane or the User Include Path Pane. Then, click the Add button. The dialog shown in Figure 7.10 appears.

    Use the standard BeOS controls to navigate to the folder you want to add to the Access Paths.

    You can choose how the BeIDE will store the access path with the three radio buttons above the Add Default button. The three buttons are Absolute Path, Project Relative, and IDE Relative.

    Figure 7.10 Add an Access Path Dialog



    Click the Add button in the Add an Access Path dialog, and CodeWarrior adds the Access Path to the list. Click the Done button to close the dialog.


    NOTE:

    You can also drag & drop directories to add them into the Access Paths list.

    Change

    To change an access path, select a path in the Project Include Path Pane or the System Include Path Pane, and click the Change button. The dialog shown in Figure 7.11 appears. Use this dialog to navigate to the location of the access path you want to change to.

    Figure 7.11 Change Access Path Dialog


    To learn more about the options in the dialog, refer to "Add."


    Remove

    To remove an access path, select the Project Include Path Pane or the System Include Path Pane, and click the Remove button. The path is removed.


    Target

    The Target settings panel, shown in Figure 7.12, is used to associate a file name extension such as .c or .p with a plugin compiler. This tells CodeWarrior which compiler to use when a file with a certain name if encountered.

    Figure 7.12 Target settings panel


    When you change the target or application type, you must change the libraries contained in the project. Creating a new project does this for you automatically. Choosing a new value for a Target does not change these files for you. For this reason, you should be careful when changing values in this section.


    WARNING!

    To change the target or project type, it's best to create a new project and add the source code files from the old project.


    File Name List

    The File Name List contains a Filetype, associated extension, and compiler choice for each .* file name extension. This list tells CodeWarrior which compiler to invoke when a given file name and extension is encountered.

    To add a new extension to this list, edit the File Type and Extension fields, and click the Add button.


    NOTE:

    To add the new file kind to all new empty projects, make sure you close your Project window (if it is open).

    File Type

    This field allows you to enter a MIME file type such for an entry in the target list.


    Extension

    This field allows you to enter a file name extension such as .c or .h.


    Tool Name

    This popup allows you to choose a plug-in tool for the file you are working with in the File Name List.


    Flags

    Use the Flags popup to set the Make stage when a tool will be invoked for a specific Filetype during a Make operation.


    Ignored by Make

    Choose this option to ignore this Filetype during compiling or linking. This is useful if the files contain comments or documentation that you want to include in the project.


    Precompile Stage

    Choose this option to compile the Filetype before other files.


    Compile Stage

    Choose this option to compile the Filetype during the normal Compile stage.


    Link Stage

    Choose this option to link the Filetype during the Linking stage.


    PostLink Stage

    Choose this option to link the Filetype during the Post-linking stage.


    Has Resources

    Choose this option when the Filetype has resources associated with it that should be included in the finished product.


    PPC Project Panel

    Use the PPC Project Panel to specify the type of project you are creating as well as setting vital final product information.

    Figure 7.13 PPC Project settings panel



    Project Type

    Choose from the Project Type popup the type of project you are compiling.


    Application

    Choose Application to create a standalone program.


    Shared Library

    Choose Shared Library to create a library of functions that can be shared among application and other libraries like a Browser add-on. A Shared Library does not run by itself, nor does it need to be compiled into an application that uses it.


    Library

    Choose Library to create a static library of functions that applications and other libraries can use. A Library does not run by itself. Each program that uses a Library contains a copy of the Library within itself.


    File Name

    When the BeIDE creates the final product file, it assigns to the file the name specified in the File Name field.


    File Type

    When the BeIDE creates the final product, it assigns the file the MIME type specified in the File Type field.

    Table 7.3 Valid file types.

    application/x-be-executable
    shared libraries, applications, and add-ons
    application/x-mw-library
    static libraries


    x86 Project Panel

    Use the x86 Project Panel to specify the type of project you are creating as well as setting vital final product information.

    Figure 7.14 x86 Project settings panel



    Project Type

    Choose from the Project Type popup the type of project you are compiling.


    Application

    Choose Application to create a standalone program.


    Shared Library

    Choose Shared Library to create a library of functions that can be shared among application and other libraries like a Browser add-on. A Shared Library does not run by itself, nor does it need to be compiled into an application that uses it.


    Library

    Choose Library to create a static library of functions that applications and other libraries can use. A Library does not run by itself. Each program that uses a Library contains a copy of the Library within itself.


    File Name

    When the BeIDE creates the final product file, it assigns to the file the name specified in the File Name field.


    File Type

    When the BeIDE creates the final product, it assigns the file the MIME type specified in the File Type field.

    Table 7.4 Valid file types.

    application/x-be-executable
    shared libraries, applications, and add-ons
    application/x-mw-library
    static libraries


    Base Address

    The edit field Base Address allows you to specify the base address of your application in the Link Map file.

    For further information on how to create a link map file, see "Generate Link Map."


    Language Settings Panels

    You can change many different language settings to configure CodeWarrior to build your project the way you want. This section discusses the changes you can make to Language settings specific to your project.

    The topics in this section include:


    C/C++ Language

    There are several settings you can configure to tailor the C/C++ compilation of your project's source code files, as shown in Figure 7.15. You may also refer to the C, C++ and Assembly Language Reference manual for detailed information on these options.

    Figure 7.15 C/C++ Language settings panel



    Activate C++ Compiler

    Compiles all .c files as C++ files.


    Enable C++ Exceptions

    Allows use of the try and catch statements for exception handling.


    NOTE:

    Required option for building BeOS projects.

    Enable RTTI

    Enables C++ Run-Time Type Information (RTTI).


    NOTE:

    Required option for building BeOS projects.

    Require Function Prototypes

    This option tells the compiler to require that all functions be declared prior to definition.


    Inline

    Allows you to choose how to inline your functions. You can inline only those functions declared inline, let the compiler choose, or inline nothing.


    Enums Are Always Int

    Makes all enumerated types the size of an int. To make an enumerated type the size of the closest integral type, turn this option off.


    NOTE:

    Required option for building BeOS projects.

    Pool Strings

    Stores all string constants in one data object. To create a data object and TOC entry for each string constant, turn this option off.


    Don't Reuse Strings

    Stores each constant separately. To store only one copy of identical string constants, turn this option off.


    Prefix File

    This option tells the compiler which file to preprocess prior to compilation of each source code file.


    ANSI Strict

    Generates an error message when you use the Metrowerks extensions to the C and C++ langauges. These extensions include:

    For more information on these extensions, see the "C, C++, Assembly Language Reference."


    ANSI Keywords Only

    Recognizes only the ANSI standard keywords. To recognize these additional words (asm, far, inherited, and pascal), turn off this option.


    Expand Trigraphs

    Tells the C++ compiler to recognize trigraph characters.


    Enable bool Support

    Check the Enable bool Support option if you want touse the standard C++ bool type to recognize true and false. Uncheck this option if recognizing bool, true, or false as keywords would cause problems in your program.


    NOTE:

    Required option for building BeOS projects.

    Use Unsigned Chars

    Check Use Unsigned Chars to have the C++ compiler treat char declarations as if they were unsigned char declarations.


    NOTE:

    If you turn this option on, your code may not be compatible with libraries that were compiled with this option turned off.

    Relaxed Pointer Type Rules

    When you turn on the Relaxed Pointer Type Rules option in the C/C++ Language Settings panel, the compiler treats char*, unsigned char*, and Ptr as the same type. This option is especially useful if you're using code written before the ANSI C standard. Thi sold code frequently used these types interchangeably. When compiling C++ code, the compiler ignores the settings of this option and always treats the types as different types.


    C/C++ Warnings

    The C/C+ Warnings settings panel, shown in Figure 7.16, allows you to configure the warning messages that are emitted during compilation of your C and C++ code.

    Figure 7.16 C/C++ Warnings settings panel



    Treat All Warnings As Errors

    If enabled, this option causes the compiler to treat any warning messages that occur as fatal compilation errors. Compilation will not complete successfully if this option is enabled and a warning message is generated.


    Illegal Pragmas

    This option warns about pragma keywords that the compiler doesn't understand. If you turn this option off you will not be notified about any pragma directives that the compiler doesn't understand.


    Empty Declarations

    This option, if enabled, warns about declarations that contain no variables.


    Possible Errors

    This option, if enabled, warns about possibly-unintended semicolons, or confusing assignment ( = ) and equivalence ( == ) operators that are used in your code.


    Unused Variables

    This option, if enabled, warns about a variable you declared but didn't use.


    Unused Arguments

    This option, if enabled, warns about a function argument that you named in the argument list but didn't use.


    Extra Commas

    This option, if enabled, warns about extra commas.


    Extended Error Checking

    This option, if enabled, warns about some common type misuses that are legal C and C++ code, but could lead to hazardous results.


    Hidden Virtual Functions

    This option, if enabled, warns about non-virtual member functions that hide virtual functions in the superclass.


    Large args passed to unprototyped functions

    This option, when enabled, warns you when you pass a "long long" or floating point value to an unprototyped function. When compiling old-style C programs, type conversion for numeric types larger than "int" do not happen.

    All of the above warnings can be avoided by using a PRAGMA setting within your source code. See the "C Compiler Guide" for additional information.


    Code Generation Settings Panels

    You can change many different code generation settings to configure CodeWarrior to build your project the way you want. This section discusses the changes you can make to Code Generation settings specific to your project.

    The topics in this section include:


    PPC Processor

    Use the PPC Processor Panel to specify options to the PowerPC C/C++ compiler about how string constants, static data, floating point calculations, and optimization levels when compiling files in your project.

    Figure 7.17 PPC Processor Settings Panel



    Make Strings Read Only

    Use the Make Strings Read Only option to specify where string constants are stored. If this option is on, the compiler stores string constants in the code section (class RO). If this option is off, string constants are stored in the data sections (class RW).


    Store Static Data in TOC

    When Store Static Data in TOC is turned on, the compiler makes your code smaller and faster by storing static variables of 4-bytes or smaller directly in the TOC. When Store Static Data in TOC is turned off, static variables are stored elsewhere and pointers to them are stored within the TOC.


    Use FMADD and FMSUB

    When Use FMADD and FMSUB is turned on, the compiler uses PowerPC instructions like FMADD, FMSUB, and FNMAD to speed up floating point computations. However, certain computations give unexpected results when this option is on. For example:


       register double A, B, C, D, Y, Z;
       register double T1, T2;
      
       A = C = 2.0e23;
       B = D = 3.0e23;
      
       Y = (A * B) - (C * D);
       printf("Y = %f\n", Y);
       /* prints
       2126770058756096187563369299968.00000 */
      
       T1 = (A * B);
       T2 = (C * D);
       Z = T1 - T2;
       printf("Z = %f\n", Z);
       /* prints 0.000000 */

    When this option is off, Y and Z have the same value.


    Peephole Optimization

    Peephole optimizations are small optimizations that eliminate some compare instructions and improve branch sequences.


    Instruction Scheduling

    Use the Instruction Scheduling popup to choose how the compiler rearranges instructions to increase speed. It rearranges instructions so that execution of one instruction doesn't hold up the execution of the others, whenever possible.

    CodeWarrior lets you choose the type of scheduling that works best for each PowerPC chip. You can choose 601, 603, 604, and off.


    Optimize For

    You can choose to optimize for Speed or Size by using the Optimize For popup menu. The default setting is Speed.


    Speed

    The compiler creates fast object code at the expense of size.


    Size

    The compiler creates smaller object code at the expense of speed. The compiler ignores the inline directive and generates function calls to call any function declared inline.


    Global Optimization Level

    Choose from four levels of global optimization using the Global Optimization Level popup. The higher the number, the more optimizations.


    Level 1

    Level 1 provides dead code elimination, and global register allocation.


    Level 2

    Level 2 provides common subexpression elimination, copy propagation, dead code elimination, and global register allocation.

    Level 2 is the best choice for most coding projects.


    Level 3

    Level 3 provides common subexpression elimination, loop invariant code motion, strength reduction, copy propagation, loop transformations, dead code elimination, and global register allocation.

    Level 3 is the best choice for projects containing many loops.


    Level 4

    Level 4 provides repeated common subexpression elimination and loop invariant code motion, strength reduction, copy propagation, loop transformations, dead code elimination, and global register allocation.

    Level 4 optimizes loops even more than Level 3, plus it performs CSE and code motion optimizations a second time to take advantage of additional opportunities exposed by the loop optimizations.


    Generate Profiler Information

    To generate profiler information at compile time, enable this checkbox.


    Emit Traceback Table

    Turn on Emit Traceback Table to tell the compiler to generate an AIX-formated table for each function andplace it into the executable code. Traceback Tables can enable other people to debug your application or shared library if you do not distribute the source code.


    PPC Disassembler

    Use the PPC Disassembler settings panel to set the level of detail included in the source code file displayed in a new window.

    Figure 7.18 PPC Disassembler settings panel



    Show Code Modules

    Turn on Show Code Modules to display code modules in the disassembled source code window.


    Use Extended Mnemonics

    Turn on Use Extended Mnemonics to display extended assembler mnemonics in the disassembled source code window.


    Show Source Code

    Turn on Show Source Code to view the source code from the original source file. When turned off, only the disassembled code is displayed.


    Show Only Operands and Mnemonics

    Turn on Show Only Operands and Mnemonics to include only operands and mnemonics in the disassembled source code window.


    Show Data Modules

    Turn on Show Data Modules to include the contents of the data modules in the disassembled source code window.


    Disassemble Exception Tables

    Turn on Disassemble Exception Tables to include the contents of the exception tables in the disassembled source code window.


    Show SYM Info

    Turn on Show SYM Info to include the project SYM information in the disassembled source code window.


    Show Name Table

    Turn on Show Name Table to include the contents of the project name table in the disassembled source code window.


    x86 Global Optimizations

    The x86 Global Optimizations panel, shown in Figure 7.20, is available when BeOS x86 C/C++ is the selected target in the Target settings panel. This panel is used to instruct the compiler to rearrange its object code to produce smaller and faster-executing object code. Some optimizations remove redundant operations in a program, other optimizations analyze how an item is used in a program to attempt to reduce its affect on a program's performance.

    All optimizations rearrange object code without affecting the object code's logical sequence of execution. In other words, an unoptimized program and its optimized program produce the same results.


    NOTE:

    Use compiler optimizations only after you've debugged your software. Using a debugger on a program that has been optimized may affect the debugger's source code view.

    Figure 7.19 x86 Global Optimization panel


    The options in this panel are:


    Optimize for Space

    When this option is enabled, the size of object code that the compiler produces is reduced. Note that when this option is enabled, the object code produced is smaller, but may be slower.


    TIP:

    Enable the option Optimize for Speed to reduce the effect that this option has on a program's performance.

    Common Subexpression Removal

    Replaces similar redundant expressions with a single expression. For example, if two consecutive statements both use the expression a * b * c + 10, the compiler generates object code that computes the expression only once and applies the resulting value to both statements.

    With this option on, object code is smaller and faster.


    Copy/Const Propagation

    Replaces multiple occurrences of one variable with a single occurrence.

    With this option on, object code is smaller and faster.


    Strength Reduction

    Replaces multiplication instructions that are inside loops with addition instructions to speed up the loop.

    With this option on, object code is larger but executes faster.


    Lifetime Analysis

    Uses the same processor register for different variables in the same routine if the variables aren't used in the same statement.

    With this option on, object code executes faster.


    Optimize for Speed

    Improves the execution speed of object code.

    With this option on, object code is faster, but may be larger. Turn on Optimize Space to reduce the effect that this option has on a program's size.


    Hoist Loop Invariants

    Moves computations that don't change on the inside of a loop to the outside of a loop to improve the loop's speed.

    With this option on, object code is faster.


    Dead Store Elimination

    Removes assignments to a variable if the variable is not used before being reassigned again.

    With this option on, object code is smaller and faster.


    Dead Code Elimination

    Removes statements that, logically, can never be executed or are never referred to by other statements.

    With this option on, object code is smaller.


    x86 CodeGen

    The x86 CodeGen panel (Figure 7.20) contains settings related to code generation for x86 processors.

    Figure 7.20 x86 CodeGen settings panel


    The options in this panel include:


    Byte Alignment

    The Byte Alignment setting specifies the alignment boundary for structure and class members. Each member is aligned on a multiple of either the specified alignment or the size of the member, whichever is smaller. For example, if you set the byte alignment to 16 and the member's size is 2 bytes, it will be aligned on a 2-byte boundary; if the byte alignment is 4 and the member's size is 8, it will be aligned on a 4-byte boundary. If the byte alignment is set to 1, all members will start on the next available byte, with no padding between members. Setting Byte Alignment to 4 or 8 can improve execution speed, but with a penalty in memory usage if structures have wasted space.


    Peephole Optimizer

    Peephole optimization is a processor-dependent technique in which the compiler attempts to generate smaller and faster code by looking for specific sequences of instructions and replacing them with equivalent but more efficient sequences. You can usually leave this setting turned on.


    Machine Code Listing

    When enabled, the option Machine Code Listing generates a .asm file for each source file compiled. The .asm file is saved at the same location as your source file.

    For more information on the disassembler, see "Disassembling Source Code."


    Register Coloring

    The Register Coloring setting instructs the optimizer to analyze the lifetimes of local variables and temporaries so that it can utilize registers more effectively: for instance, by assigning two variables to the same register if their lifetimes don't overlap. The resulting optimization can generally reduce both code size and execution time.


    Inline Intrinsic Functions

    The Metrowerks x86 C/C++ compiler provides intrinsic functions to generate inline x86 instructions. These intrinsic functions execute faster than other functions, because the compiler translates them into inline assembly instructions instead of function calls. A list of the function calls available for inlining is listed in Table 7.5.

    To tell the compiler to inline these functions, enable this option.

    Table 7.5 Functions available for inlining under the x86 C/C++ compiler

    _ALLOCA
    _MEMMOVE
    _MEMCOPY
    _STRCOPY
    _SIN
    _COS
    _TAN
    _ATAN
    _ATAN2
    _ACOS
    _ASIN
    _LOG10
    _LOG
    _EXP
    _POW
    _FSQRT
    _FABS


    NOTE:

    Support for intrinsic functions is not part of the ANSI C or C++ standards. They are an extension provided by the CodeWarrior compilers.

    Linker Settings Panels

    You can change many different linker settings to configure CodeWarrior to build your project the way you want. This section discusses the changes you can make to Linker settings specific to your project.

    The topics in this section include:


    PPC Linker

    The PPC Linker settings panel, shown in Figure 7.21, allows you to configure the linker options for your PowerPC-based project.

    Figure 7.21 PPC Linker settings panel


    The options in this panel include:


    Generate SYM File

    CodeWarrior will create a SYM file for your project the next time it makes your project. To determine which source files CodeWarrior includes in that SYM file, use the SYM markers in the Project window.


    Use Full Path Names

    CodeWarrior puts the full pathname of the source file in the SYM file. Turning on this option is recommended. However, it slightly increases the size of your SYM file.


    Generate Link Map

    The Metrowerks C/C++ compilers let you create a link file that contains function and class section information on the generated object code.


    Suppress Warning Messages

    To prevent the PPC linker from reporting non-fatal warning messages, turn on the Suppress Warning Messages option in the PPC Linker preference panel. This option does not affect the warning messages displayed by other parts of CodeWarrior, including the C/C++ compilers.


    Dead-strip Unused Static Initialization Code

    CodeWarrior lets you choose whether to strip initialization code for variables you don't use.

    If Dead-strip Static Initialization Code option is in, the linker removes runtime initializations and constructor calls for all the static and global objects in a file if your program does not refer to any variables or functions in that file.

    For example, suppose that a project contains the files A.cp, B.cp, C.cp. The main() function in A.cp calls functions in B.cp but not in C.cp, and C.cp has some global variables of types which have constructors. The compiler generates code called a static initializer which calls the constructors for the variables in C.cp.

    If this option is on, the linker recognizes that no references are made to any of C.cp's variables, so the linker does not link the variables or the static initializers for them into the program.

    If this option is off, the linker leaves the variables and the static initializer in, and it may end up linking in variables and functions that the program never uses.

    In general, leave this option on to produce smaller and faster code. However, if your program expects the static initializers to be executed for their side-effects, turn this option off.


    Entry Points

    To create applications, shared libraries, and add-ons, the Initialization and Termination fields must contain _init_routine_ and _term_routine_ respectively. The Main field should contain __start only when creating applications.

    For debugging to work, make sure that you have Generate SYM File enabled.


    PPC PEF

    Use the PEF panel to specify how to export symbols.

    Figure 7.22 PEF SettingsPanel



    Export Symbols

    The Export Symbol options include:


    None

    Export no symbols. This option is most often used for applications.


    All Globals

    Export every global symbol.


    Use #pragma

    Mark the symbols in the source file with a pragma. This option is most often used when creating shared libraries.

    See the "C, C++, and Assembly Language Reference" for additional information.


    Use ".exp" file

    Export only those symbols listed in a specially named .exp file. This option is most often used when creating shared libraries.

    See the "C, C++, and Assembly Language Reference" for additional information.


    x86 Linker

    The x86 Linker settings panel, shown in Figure 7.21, allows you to configure the linker options for your PowerPC-based project.

    Figure 7.23 x86 Linker settings panel


    The options in this panel include:


    Generate SYM File

    CodeWarrior will create a SYM file for your project the next time it makes your project. To determine which source files CodeWarrior includes in that SYM file, use the SYM markers in the Project window.

    For debugging to work, make sure that Generate SYM File is enabled.


    Use Full Path Names

    CodeWarrior puts the full pathname of the source file in the SYM file. Turning on this option is recommended. However, it slightly increases the size of your SYM file.


    Generate Link Map

    The Metrowerks C/C++ compilers let you create a link file that contains function and class section information on the generated object code.


    Suppress Warning Messages

    To prevent the x86 linker from reporting non-fatal warning messages, turn on the Suppress Warning Messages option in the x86 Linker preference panel. This option does not affect the warning messages displayed by other parts of CodeWarrior, including the C/C++ compilers.


    Entry Point

    The Main field should contain __start only when creating applications.

    The text box labeled Command File specifies the name of the linker command file, an optional text file containing additional commands for controlling the operation of the linker.


    Other Settings Panels

    You can change many different language settings to configure CodeWarrior to build your project the way you want. This section discusses the changes you can make to Language settings specific to your project.

    The topics in this section include:


    Res Tool

    This panel currently has no options available.


    Shell Tool

    Use the Shell Tool to send commands to the BASH shell during any Make stage defined in the Target. This panel is show in Figure 7.24.

    Figure 7.24 Shell Tool Panel



    For example, you can create a shell script to beep when a Make or Compile is finished using the Shell Tool.

    1. Create a shell extension.

    In the Target, add a new target of type TEXT, extension "sh", choose the "sh" tool, and the PostLink Stage flag.

    2. Create a shell script file.

    Create a shell script from within the CodeWarrior IDE and save it with your other project files. A simple script is shown below that simply beeps when executed:


       /boot/bin/beep

    3. Add the shell script to project.

    Now, add the shell script file to your project either using Add to Project in the Editor window or Add Files from the Project window.

    4. Run the project.

    Choose Run from the Project Menu. When the PostLink Stage is executed, the Shell Tool executes the script in the shell script file.





    Visit the Metrowerks website at: http://www.metrowerks.com
    For assistance contact Metrowerks Technical Support at: support@metrowerks.com
    Copyright © 1998, Metrowerks Corp. All rights reserved.

    Last updated: February 15, 1998 * Chris Magnuson * John Roseborough