Installing Pascal with CodeWarrior 8
Vik Rubenfeld, Programmer



INSTALLING PASCAL WITH CODEWARRIOR 8
Vik Rubenfeld
vikr@mindspring.com
Updated: Feb 24, 2004

Update: Please see also the document "CodeWarrior 8.3 and Panther",
available at Pascal-Central.

CW 8 appears to work very well with the MW Pascal Compiler. Here's how to install Pascal with CodeWarrior 8.

Contents


INSTALL DEVELOPER'S TOOLS

Download and install the December 2002 Developer's Tools from Apple at
<
http://developer.apple.com/tools/macosxtools.html>.

CW 8.3 will not run with the Developer's Tools that are included on the CW 8.0 CD. CW 8.3 requires at least the August or December 2002 Developer's Tools.

Note: CW 7 will _not_ work with the December 2002 Developer's Tools.

INSTALL CODEWARRIOR 8.3

Run the Installer on the CW 8 Installation CD.

Download the CW 8.2 and 8.3 patches from MetroWerks at
<
http://www.metrowerks.com/MW/Download/default.htm> and install them.

REBUILD C LIBRARIES

When you finish installing the 8.3 patch, the 8.3 Installer will offer you the chance to open a Build All Libraries project. Open that project. Go to Edit Menu->Preferences->Build Settings and confirm that Include File Cache is set to 0.

Note: setting this to a non-zero value will crash the compiler.

Now select Build All from the Targets pop-up in the Project window, and build the project.

INSTALL THE PASCAL PATCH

Quit out of CW 8.3. Download the Pascal patch from MetroWerks.

Download via HTTP
Download via FTP

Install it.

REBUILD THE PASCAL MSL LIBRARIES

Open the project "MSL_Pascal.PPC.Mtarg.mcp" located in "Metrowerks CodeWarrior 8.0/Metrowerks Codewarrior/MSL/MSL_Pascal/MSL_MacOS/PPC/Project".

Click on the Targets tab in the Project window. Remove the targets "Rt PPC TOOL (opt.)" and "Rt PPC TOOL (dbg.)" (To remove them, select them and then click Clear on the Edit menu.) Those two targets were used with MPW, which
CW 8 no longer references.

Now click on the Files tab in the Project window. In the IO group, find the file "API_Support.c" and open it. Find the line:

#include <time.h>

and change it to:

#include <time_api.h>

Now select Build All from the Targets pop-up in the Project window, and build the project.

USE 68K STRUCT ALIGNMENT IN YOUR OWN PROJECTS

In your own projects, select Edit Menu->Project Settings->PPC Processor, and make sure Struct Alignment is set to 68k.

SETLIB CORRECTIONS

Joe van Tunen found some anomalies in the Pascal MSL file, "SetLib.c". The following link offers a corrected version of Setlib.C.

http://pascal-central.com/source-code/setlib.hqx

TROUBLESHOOTING

IF YOUR PROJECT COMPILES BUT THE DEBUGGER WON'T LAUNCH
or
CW GIVES YOU AN "UNABLE TO OPEN PROJECT" MESSAGE
or
IF YOUR PROJECT COMPILES WITH ERROR MESSAGES IT DIDN'T HAVE IN CW 7

It probably means some or all of your source files are nested too deeply within folders and sub-folders. This is a known bug in GDB, the CW Debugger. It is especially likely in OS X since your documents are likely already several folders deep in a user/documents folder. Move the folders containing your source files as close as possible to the root level of the volume; for example, put them at the top level of your user/documents folder.

IF YOUR PROJECT COMPILES BUT THE DEBUGGER WON'T RUN, GIVING YOU AN MESSAGE
SAYING IT DOESN'T HAVE ACCESS TO A REQUIRED FILE


It means CW doesn't have read/write permission to the folder your built application is in. Quit CW. In the Finder, select the folder your built application is in. Select File Menu->Get Info. Reset the permission on the folder. (If you wish to remove all access restrictions, give all users read/write permission and unlock the folder by clicking on the lock icon). Then open CW and proceed.

A NOTE ON GDB

With CW 7, it was necessary to replace the CW-supplied copy of GDB, with one that came with the Developer Tools. This is no longer necessary.


A NOTE ON STRUCT ALIGNMENT

There is a bug in the Pascal Preferences panel that can prevent a project from compiling unless Struct Alignment (Edit Menu->Project Settings->PPC Processor) is set to 68k. However, there is an easy workaround for those who wish to use PowerPC Struct Alignment. Per John Gee, on the MacPascal list:

...you get Pascal compiler errors if you use a record which contains floating point fields, if the preferences pane is set to any of the PowerPC alignments: Code Generation > PPC Processor > Struct Alignment

This is not quite as bad as it sounds, since while you must specify 68k in the preferences pane, you can change the alignment back to PowerPC in the code, including in the prefix file: {$ALIGN PowerPC}


Apple has stated that apps running on PowerPC chips will run faster when PowerPC Struct Alignment is used.


A NOTE ON CODEWARRIOR PRO 9


Per Metrowerks, the Pascal compiler does not work with CodeWarrior Pro 9. However, CodeWarrior Pro 8 continues to work under Panther (OS 10.3) with Pascal.

Adriaan van Os is developing a Pascal compiler plug-in (based upon GNU Pascal) that will work with the latest versions of CodeWarrior. Contact Adriaan
<macpascal "at" microbizz.nl> for further information on this compiler. As of November 2003, Adriaan anticipates making his plug-ins available for a very reasonable price of $128 Euros (~$151 US).

FIXING SIOUX UNDER CODEWARRIOR PRO 8.3 AND PANTHER


Jack Bozzuffi provides this note on installing Pascal on CW Pro 8.3/Panther:

I noticed that some programs that ran perfectly in CodeWarrior 3.3 on OS 9.1 under ANS console PPC using the ANS Pascal model were generating errors around code that used the SIOUXclrscr procedure from the SIOUX Library under CW Pro 8.3/Panther. Gale Paeper pointed out that the SIOUXclscr procedure in the SIOUX.p file went through a name change somewhere along the way, and that in the process, one field of the record was omitted.  

Here are the details about how to correct this:

Follow the path:  Metrowerks CodeWarrior 8.0/Metrowerks CodeWarrior/Mac OS
Support/MWInterface/SIOUX.p

  1. If your version of SIOUX.p has a procedure defined as:  PROCEDURE SIOUXclrscr; C; EXTERNAL;  simply rename it to read PROCEDURE clrscr; C; EXTERNAL;   

  2. Likewise, if you are going to use the SIOUXSettings variable to change the default settings, you probably need to add a field to the record:   In the TYPE section of SIOUX.p,  if the tSIOUXSettings record declaration doesn't have a "sleep" field after the "fontface" field, add the following after the "fontface :  INTEGER:" line:  

       sleep: INTEGER;  (* Value to pass to WaitNextEvent for the sleep time ... *)

  3. After making sure that you have the latest SIOUX.p up to date, I had to go back to my old programs and do a global "find/replace all" to change all of the calls to the old procedure SIOUXclrscr to now call the new, improved procedure clrscr.    

  4. In order to have tSIOUXSettings fully match the declaration in SIOUX.h, refer to the Sioux under CodeWarrior 8 document on what changes to make to SIOUX.p.



Copyright © 2003-2004, Vik Rubenfeld.