How to Use CodeWarrior

Here's a step-by-step account of how to run a simple C program in CodeWarrior.

First, find a computer that has CodeWarrior installed ( for instance, a PowerPC in Korman 263.) Get into the Finder program (to do this, click on the icon at the far right of the menu: Finder should be listed there.) Under File in the menu, click on Find. In future I will write this as "File/Find". When the Find window comes up enter "codewarrior", then choose the following:

CodeWarrior C/C++
CodeWarrior IDE 1.6.3
If you clicked twice on "CodeWarrior IDE 1.6.3", you should now have a menu at the top of the screen, including options such as "Project". You are now in CodeWarrior.

First, write your program. Choose File/New. Choose File/ Save as, and save your file with a reasonably meaningful name, ending in .c. (For instance, "greetings.c".) IMPORTANT: the .c at the end of your file name is the way the computer recognizes that this is a program written in C. Your program name MUST end in .c. (If you're writing in C++, end your program name with ".cc".)

Now write your program using standard Mac editing and Save it again. Close the program window.

Now, build a project window. The project window contains all the different programs that you will ask the computer to link together. For instance, when you write "printf" in your own program, how does the computer know what that means? It knows because it finds a definition of "printf" in a library that you have included in the project window.

So choose File/New Project. When the project window comes up, at the bottom, where it says "Project Stationery", choose "~Ansi 68k C.mu". (Choose "~Ansi 68k C++.mu" if you're writing in C++.) This is a library of basic C functions, such as "printf". Give your project a name ending in ".mu". Mu is a Greek letter which can be obtained by pressing "option-m" on the keyboard.

You need to add the program you've just written to the project. Highlight "sources" in the project window; this is where your program will be added. Choose Project/Add Files. Find your program, highlight it, and click on Add. Then click on "Done."

The project window may contain a line that says "replace me.c". This is a special feature that the CodeWarrior programmers put in to annoy you. Highlight the line that says "replace me" and choose Project/Remove Files to remove the "replace me" file.

Now you're ready to run it! Choose Project/Run and see what happens. If you get an error message, read the message carefully and try to correct the situation. The error messages are reasonably informative. If the program ran correctly, you should see an output window (labeled "Mac OS 68k C/C++.out"). To print the contents of the output window, choose File/Print. When the print window comes up, try to verify that you're routing your file to a public/student printer. I routed mine to Dr. Nira Hermann's office by mistake; fortunately she wasn't around to object.

To print your program (it's better to run it first to make sure it works), choose File/Open, open your program file, and choose File/ Print as above.

Beth Randall's Tips for Students
Beth Randall's Home Page