This chapter describes how to get CodeWarrior® installed and running. For new CodeWarrior IDE 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:
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 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, double-click the My Computer
icon on the Windows desktop, then double-click the drive that
holds the CodeWarrior CD. When you do, a dialog appears with a
button titled "Launch CodeWarrior Setup." Click this button. If
for some reason you do not see this dialog, double-click the setup.exe file located at the root level of the CD.
A proprietary multi-language, multi-target compiler architecture is at the heart of the CodeWarrior IDE. Front-end language compilers generate a memory-resident, unambiguous, language-independent intermediate representation (IR) of your syntactically correct source code. Back-end compilers generate code from the IR for specific targets. The CodeWarrior IDE manages this entire process.
As a result, 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 the compilers and linkers is public; hence, third parties are free to create compilers that work with the CodeWarrior IDE. For more information on creating your own plug-ins for the CodeWarrior IDE, refer to the CodeWarrior IDE Plugin Manual.
Once the compiler generates object code, a plug-in linker generates the final executable. Some targets have multiple linkers available to support different object code formats.
Programming with CodeWarrior for Win32 is much like programming for any other target. If you have never used the CodeWarrior IDE before, the features you will need to become familiar with are:
If you are already an experienced CodeWarrior IDE user, then you already know how to use the IDE and Debugger, as these components are identical for every supported target. You will, however, need to become familiar with the Win32/x86 runtime software environment.
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, making the organization of and navigation among your source code files easier. 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. You can learn more about multi-target projects in the IDE User Guide.
For more information about how the CodeWarrior IDE compares to a command-line environment, see "The CodeWarrior IDE Development Process," which 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 Win32/x86 platform. Other CodeWarrior packages include C, C++, and Java compilers for Win32, Mac OS, and other platforms. The plug-in architecture is described in the CodeWarrior IDE Plugin Manual.
For more information about using the CodeWarrior IDE, refer to the IDE User Guide.
The CodeWarrior integrated debugger is part of the IDE. The debugger functions allow you to control your program's execution and see what is 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, refer to the IDE User Guide.
For more information about debugging software specific to the Win32/x86 targets, see "Debugging for Win32/x86."
The Mac-OS-hosted version of the CodeWarrior debugger includes remote debugging capabilities for Win32/x86 applications. This is a two-machine debugger that runs on the Mac OS host and communicates with the running application via a remote communications nub on the x86 target computer, via a direct serial connection or a TCP/IP network connection. Using the remote debugger requires specialized setup procedures, which are discussed in "Setting Up for Remote Debugging."
The CodeWarrior C/C++ compiler for Win32/x86 is an ANSI compliant C/C++ compiler. It is based on the same compiler architecture used in all CodeWarrior C/C++ compilers. When used with the CodeWarrior linker for Win32/x86, you can generate Win32/x86 applications and libraries that conform to Microsoft specifications.
For more information about the CodeWarrior C/C++ language implementation, refer to the C Compiler Reference. For information on the Win32/x86 back-end compiler, see "Target Settings for Win32/x86" and "C and C++ for Win32."
In addition, the C/C++ compiler supports inline assembly for Win32/x86 development. See "Assembly Code Support."
The Win32 resource compiler (RC) is another plug-in tool for the CodeWarrior IDE. It reads standard Win32 resource scripts and compiles them into resources that are then linked into your project's object file. See "Creating Win32 Resources" for more information.
Like the compilers, the CodeWarrior Win32/x86 linker is a plug-in tool integrated into the CodeWarrior IDE. It links multiple object modules and libraries, resolving references from one to another to produce executable applications, dynamic link libraries (DLLs), or static libraries.
When you execute a Make command in the CodeWarrior IDE to build your project if any of
the project's object files or libraries have changed since the
last build, the CodeWarrior IDE automatically invokes the linker
as the last step in the build process.
When linking your project, the linker reads these files:
.lib is treated as a COFF library.
The linker can generate any of the following as output:
A COFF/PE executable file (file extension .exe). This is the standard-format executable file for all Win32 systems.
A COFF/PE dynamic link library, or DLL (file extension .dll). DLLs are in the same format as applications, but do not run
on their own. They are used by other applications to link dynamically
to other code at load or run time. A COFF Library (LIB) file.
The CodeWarrior Win32/x86 linker is more like the Mac-targeting linkers now when resolving symbols from static libraries. In order to override a symbol from a static library, it is no longer necessary to override every symbol exported from the object file in the static library. Before, you would have to copy the source file from MSL and change whatever function needed changing. The linker now allows function-level overrides, negating the need to override symbols manually in this context.
For more information about the linker, see "x86 Linker."
Refer to the following address on the web for more information on COFF files:
http://www.pc.com/design/intarch/papers/esc_file.htm
The Metrowerks Standard Libraries (MSL) are standard C and C++ libraries for use in developing applications for Win32/x86. 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 targets, but they have been customized and the runtime adapted for use in Win32/x86 development.
For more information about MSL, refer to the MSL C Reference and the MSL C++ Reference. To learn how MSL has been adapted for use in Win32/x86 applications, see "The Metrowerks Standard Libraries."
The Win32 Application Programming Interface (API) is a set of data structures and functions used to interface to 32-bit versions of the Windows operating system. The Win32 API was designed for use with C, C++, and other languages. The CodeWarrior IDE provides a complete set of header files and libraries that allow you to use all Win32 API functions from either C or C++.
The Microsoft Foundation Classes (MFC) are an object-oriented application framework that implements the key building blocks in a Win32 application. The CodeWarrior IDE includes the full MFC source.
You can learn more about MFC on the World Wide Web at:
The CodeWarrior IDE Win32/x86 development tools strive for maximum compatibility with the tools provided by Microsoft:
All this compatibility means that you can do any of the following:
Link Microsoft-created object modules and libraries with the CodeWarrior linker. Link CodeWarrior-created object modules with the Microsoft linker. Use the CodeWarrior IDE to develop code for Microsoft OLE (Object Linking and Embedding) programming model. Use dynamic link libraries created by either the CodeWarrior IDE or Microsoft's tools interchangeably. Use Microsoft Visual C++ Developer's Studio to debug your CodeWarrior-generated code. You can also use third-party debuggers and tools such as Nu-Mega Technologies' SoftICE and BoundsChecker. You can find more information about these tools on the World Wide Web at:
However, a few incompatibilities exist:
C++ multiple-inheritance classes are not compatible with Microsoft's,
so you can not mix such classes from the two compilers. Visual C uses a name mangling scheme that causes problems with
function templates and does not support all the types added to
the C++ language. The ARM conformance switch changes the x86 mangler
to be bug-compatible with Visual C++. The CodeWarrior IDE does not support the older object format used
by Borland and Microsoft prior to Visual C++. Such objects must
be converted to COFF format before the CodeWarrior IDE will accept
them. Both the CodeWarrior IDE and Visual C++ occasionally generate
code that calls library functions to handle language features.
However, the set of code that requires a library call is different,
so the CodeWarrior IDE cannot duplicate all of the undocumented
and non-public interface features of Visual C++. The CodeWarrior IDE does not yet support Microsoft-compatible
Run Time Type Information (RTTI). Both structures are pointed
to immediately before the object vtable, but the layout of the
structures is different.
While working with the CodeWarrior IDE, 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 the CodeWarrior IDE and traditional command line environments is in how the software (in this case the IDE) helps you manage your work more effectively. If you are unfamiliar with an integrated environment in general, or with the CodeWarrior IDE 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.
The CodeWarrior IDE project is analogous to a makefile. Because you can have multiple builds in the same project, the project is, in fact, 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. With the CodeWarrior IDE, these different builds within a single project are called "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.
The CodeWarrior IDE has an integral text editor designed for programmers. It handles text files in MS-DOS®/Windows, UNIX, and Mac OS 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.
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 Compile from the Project menu.
To compile all the files in the current target that have been
modified since they were last compiled, choose Bring Up To Date in the Project menu.
Linking object code into a final binary file is easy: choose the
Make command in the Project menu. 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 x86 Target settings panel to set the name of the final output file.
To debug a project, make sure Enable Debugging is selected in the Project menu.
For more information on debugging, refer to the IDE User Guide. For information specific to Win32/x86 debugging, see "Debugging for Win32/x86."
To view preprocessor output, select the file in the project window
and choose Preprocess from the Project menu. A new window appears that shows you what your file looks
like after going through the preprocessor.
You can use this feature to track down bugs caused by macro expansion or other subtleties of the preprocessor.