[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

Chapter 2.

 

Getting Started



This chapter gives you the information you need to get CodeWarrior installed and running. For new CodeWarrior users, this chapter provides a brief overview of the CodeWarrior development environment, as well as a description of the development process in CodeWarrior as compared to a command-line environment.

This chapter includes the following topics:


System Requirements


This release of the CodeWarrior IDE requires the following computer and system requirements:


Classic Mac OS Requirements


Mac OS X Requirements


Installing CodeWarrior for Mac OS

Your first step toward developing software for your target is to install the CodeWarrior tools. The tools include a variety of components such as the IDE, debugger, plug-in compilers and linkers, standard libraries, runtime libraries and headers, and all necessary documentation.

The CodeWarrior Installer automatically installs all necessary components. It is strongly recommended that you use the CodeWarrior Installer on both the Tools and Reference CD to ensure that you have all the required files. If you have any questions regarding the installer, read the instructions built into the CodeWarrior Installer itself.

To start the installation process, insert the CodeWarrior Tools or CodeWarrior Reference CD, then double-click the CodeWarrior Installer application icon, located at the root level of the CD. Read and follow the installer instructions as they guide you through the install process..


CodeWarrior Compiler Architecture

A proprietary multi-language, multi-target compiler architecture is at the heart of CodeWarrior. Front-end language compilers generate a memory-resident, unambiguous, language-independent intermediate representation (IR) of syntactically correct source code. Back-end compilers generate code from the IR for specific targets. The CodeWarrior IDE manages the whole process.

As a result of this architecture, the same front-end compiler is used in support of multiple back-end targets. In some cases, the same back-end compiler can generate code from a variety of languages.

All compilers are built as plug-in modules. The interface between the IDE and compilers and linkers is public, so third parties can create compilers that work with CodeWarrior.


NOTE

To learn how to write your own CodeWarrior plug-ins, visit the Metrowerks web site at:

	http://www.metrowerks.com/support/api/ 

to download the CodeWarrior Plug-in SDK for Macintosh.

Once the compiler generates object code, the plug-in linker generates the final executable. Some targets have multiple linkers available to support different object code formats.


Development Tools for Mac OS

Programming for the Mac OS is much like programming for any other target in CodeWarrior. If you have never used CodeWarrior before, the tools you will need to become familiar with are:

If you are an experienced CodeWarrior user, this is the same IDE and debugger that you've been using all along. You will, however, need to become familiar with the Mac OS runtime software environment. You can find a wealth of information on the web at:

	http://www.apple.com/developer/

CodeWarrior IDE

The CodeWarrior IDE is the application that allows you to write your software. It controls the project manager, the source code editor, the class browser, the compilers and linkers, and the debugger.

The project manager may be new to those more familiar with command-line development tools. All files and settings related to your project are organized in the project manager. This allows you to see your project at a glance, and eases the organization of and navigation among your source code files. The IDE manages all build dependencies.

A project may also have multiple "targets." In this context, a target is a separate build (with its own settings) that uses some or all of the files in the project. For example, you can have a debug version and a release version of your software as separate targets in the same project.

For more information about how the CodeWarrior IDE compares to a command-line environment, see "CodeWarrior Development Process." That short section discusses how various parts of the IDE implement the classic features of a command-line development system based on makefiles.

The CodeWarrior IDE has an extensible architecture that uses plug-in compilers and linkers to target various operating systems and microprocessors. The CodeWarrior CD includes a C/C++ compiler for the Mac OS family of processors. Other CodeWarrior packages include C, C++, and Java compilers for Win32, Mac OS, and other platforms.

For more information about the CodeWarrior IDE, you should read the IDE User Guide.


CodeWarrior Compiler for Mac OS

The CodeWarrior compiler for Mac OS is an ANSI compliant C/C++ compiler. This compiler is based on the same compiler architecture that is used in all of the CodeWarrior C/C++ compilers. When used with the CodeWarrior linker, you can generate applications and libraries that conform to Apple's ABI guidelines. The compiler supports statement-level and function-level assembly language.

For more information about the CodeWarrior C/C++ language implementation, you should read the C Compilers Reference. For information on the Mac OS back-end compiler, see "PPC Target panel," "Support for Motorola 68K," and "C and C++ Support for Power PC."


CodeWarrior Assembler for Mac OS

The CodeWarrior assembler for Mac OS is a stand-alone assembler that has an easy-to-use syntax. This assembler is based on Apple's MPW assembler.

For more information about the CodeWarrior assembler, you should read the CodeWarrior Assembler Guide, available on the CodeWarrior Reference CD.

In addition, the C/C++ compilers support inline assembly for 68K development. See "PowerPC Assembler."


CodeWarrior Linker for Mac OS

Like the compilers, the CodeWarrior Mac OS linkers are plug-in tools integrated into the CodeWarrior IDE. They link multiple object modules and libraries, resolving references from one to another to produce executable applications, shared libraries, static libraries, or code resources.


CodeWarrior Debugger for Mac OS

The CodeWarrior integrated debugger controls your program's execution and allows you to see what's happening internally as your program runs. You use the debugger to find problems in your program's execution.

The debugger can execute your program one statement at a time, and suspend execution when control reaches a specified point. When the debugger stops a program, you can view the chain of function calls, examine and change the values of variables, and inspect the contents of the processor's registers.

For general information about the debugger, including all of its common features and its visual interface, you should read the IDE User Guide.

For more information about debugging software for Mac OS, see "Advanced Debugging."


Metrowerks Standard Libraries

The Metrowerks Standard Libraries (MSL) are standard C and C++ libraries for use in developing applications for Mac OS. The libraries are ANSI compliant, and all of the source for the libraries is provided for you to use in your projects. These are the same libraries that are used for all CodeWarrior targets, but they have been customized and the runtime has been adapted for use in Mac OS development.

For more information about MSL, you should read the MSL C Reference and the MSL C++ Reference. See also "Library Naming Conventions" and "Application Project Libraries", "Static Library Project Libraries", "Shared Library Project Libraries", "68K Code Resource Libraries" , and "PPC Code Resource Libraries".


CodeWarrior Development Process

While working with CodeWarrior, you will proceed through the development stages familiar to all programmers: write code, compile and link, debug. For complete information on performing tasks like editing, compiling, debugging, and linking, refer to the IDE User Guide.

The difference between CodeWarrior and traditional command line environments is in how the software (in this case the IDE) helps you manage your work more efficiently. If you are unfamiliar with an integrated environment in general, or with CodeWarrior in particular, you may find the topics in this section helpful. Each topic discusses how one component of the CodeWarrior tools relates to a traditional command-line environment.

Read these topics to find out how using the CodeWarrior IDE differs from command-line programming.


Makefiles

The CodeWarrior IDE project is analogous to a makefile. Because you can have multiple builds in the same project, the project is analogous to a collection of makefiles. For example, you can have one project that has both a debug version and a release version of your code. You can build one or the other, or both as you wish. In CodeWarrior, these different builds within a single project are called "build targets."

The IDE uses the project manager window to list all the files in the project. Among the kinds of files in a project are source code files and libraries.

You can add or remove files easily. You can assign files to one or more different targets within the project, so files common to multiple targets can be managed simply.

The IDE manages all the interdependencies between files automatically, and tracks which files have been changed since the last build. When you rebuild, only those files that have changed are recompiled.

The IDE also stores the settings for compiler and linker options for each target. You can modify these settings using the IDE, or with #pragma statements in your code. When using #pragma statements in your source files, the #pragma setting will take precedence over any project settings.


Editing Code

The CodeWarrior IDE has an integral text editor designed for programmers. It handles text files in Mac OS, MS-DOS/Windows, and UNIX formats.

To edit a source code file, or any other editable file that is in a project, just double-click the file's name in the project window to open the file.

The editor window has excellent navigational features that allow you to switch between related files, locate any particular function, mark any location within a file, or go to a specific line of code.


Compiling

To compile a source code file, it must be among the files that are part of the current target. If it is, you simply select it in the project window and choose Project > Compile.

To compile all the files in the current target that have been modified since they were last compiled, choose Project > Bring Up To Date.

In UNIX and other command-line environments, object code compiled from a source code file is stored in a binary file (a ".o" or ".obj" file). The CodeWarrior IDE stores and manages object files transparently.


Linking

Linking object code into a final binary file is easy: use Project > Make. The Make command brings the active project up to date, then links the resulting object code into a final output file.

You control the linker through the IDE. There is no need to specify a list of object files. The project manager tracks all the object files automatically. You can use the project manager to specify link order as well.

Use the Target Settings panel to set the name of the final output file.


Debugging

Use the CodeWarrior debugger to watch your program as it executes, examine variable and register contents as they change, and control the program flow by starting, stopping, and stepping through the code line by line. To debug a project, just be sure to choose Project > Enable Debugging, then Project > Debug to start debugging.

For more information on debugging, refer to the IDE User Guide. For information specific to 68K debugging, see "Advanced Debugging."


Viewing Preprocessor Output

To view preprocessor output, select the file in the project window and choose Project > Preprocess. A new window appears that shows you what your preprocessed file looks like. You can use this feature to track down bugs caused by macro expansion or other subtleties of the preprocessor.

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

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

Last updated: July 21, 2000