Carbonizing Pascal under Pro 4
Koryn Grant, Pascal Programmer

Carbonizing Pascal under Pro 4


by Bill Catambay

There is more information coming out regarding carbonizing your Pascal applications, including word from Metrowerks of the "Nirvana" Pascal update, and updates from other developers on how to carbonize your Pascal projects. Koryn Grant has offered his own instructions for carbonizing Pascal projects, and includes instructions on how to create a version of Pascal.PPC.Carbon.Lib to work with your project.

Also available are
alternate instructions by Ken Beath. As usual, I'm still looking for source code submissions of sample projects which have been carbonized. To contact me or submit source code, visit the Pascal Central Submit page.

Instructions for Carbonizing Pascal
under CodeWarrior Pro 4

by Koryn Grant


Carbonized Pascal under Pro 4
Setting up the Universal Interfaces and CarbonLib
Carbonizing the Project
Creating "Pascal.PPC.Carbon.Lib"
Advanced stuff (optional)

Carbonized Pascal under Pro 4

This was done with version 3.4b1 of the Universal Interfaces (3.3.2 should also work) and CarbonLib 1.0.4. I only target PowerPC: if you have 68K targets in your projects you may need to be careful in case these changes impact on your 68K development.

Setting up the Universal Interfaces and CarbonLib

I've changed the organization of my Pro 4 "MacOS Support" folder to make it much easier to upgrade the Universal Interfaces. To do this, remove the folders:

:MacOS Support:Interfaces:MW Universal Interfaces
:MacOS Support:Interfaces:Universal Interfaces
:MacOS Support:Libraries:MacOS Common
:MacOS Support:Libraries:MacOS PPC

and put the folder "Universal" from the Universal Interfaces into the "MacOS Support" folder.

Note: If you had specific access paths (eg "{Compiler}:MacOS Support:Interfaces:Universal Interfaces:") set in your Pascal projects you'll need to remove or change them. I use "{Compiler}:MacOS Support:Universal" instead.

Note: Universal Interfaces 3.3.2 (including the Pascal interfaces) came with Pro 6. Simply copying the ":MacOS Support:Universal" folder from the Pro 6 installation worked for me.

This organization makes upgrading the Universal Interfaces simple: just replace the "MacOS Support:Universal" folder with the "Universal" folder from Apple's UI SDKs.

To set up CarbonLib copy the stub library from the Carbon SDK to the "Universal:Libraries:StubLibraries" folder, and copy the implementation library to the Extensions folder. You need to restart before the new CarbonLib is available.

Carbonizing the project

1. Target Carbon

Add the line


to the Carbon target's prefix file. Modifying the source code to be Carbon-compliant is dealt with more than adequately in Apple's Carbon porting documents.

2. Replace Libraries

In the Carbon target, replace libraries as follows:

3. Make 3rd Party Libraries Carbon-compliant

Make sure any sub-libraries in the Carbon target (e.g. MoreFiles or custom libraries) are compiled to be Carbon-compliant. This means performing the two steps above for each sub-library.

Creating "Pascal.PPC.Carbon.Lib"

1. Create Target

Create a new target for the MSL Pascal project. (I called mine "Rt PPC Carbon (opt)" with the output library named "Pascal.PPC.Carbon.Lib" for consistency with the others that are already there.)

2. Set Prefix File

Make a copy of the prefix file and add the line


to the copy. Adjust the C/C++ Language settings to use the new prefix file.

3. Remove Files

Remove the following files from the Carbon target:

These contain definitions for routines that are either not available in Carbon (PBGlue) or are provided in CarbonLib (PascalPPCGlue, StringGlue).

4. Disable UniversalProcPtrs

In the header file "MetroNubUserInterface.h" there are a bunch of conditionally compiled blocks of code like the following:

typedef UniversalProcPtr IsDebuggerRunningUPP;
typedef IsDebuggerRunningProcPtr IsDebuggerRunningUPP;

change all of these so that the UniversalProcPtrs are NOT used, e.g.:

// typedef UniversalProcPtr IsDebuggerRunningUPP;
typedef IsDebuggerRunningProcPtr IsDebuggerRunningUPP;

5. Build Library

Build the target to get the "Pascal.PPC.Carbon.Lib" library.

Advanced stuff (optional)

To make Classic source code as close as possible to the Carbon source code, add the following lines to the Classic targets' prefix files:

{ For pre-Carbon development }

and add the files


to the Classic targets only. These implement some Carbon calls that are not available in Mac OS 9 by mapping them to pre-Carbon equivalents.

Copyright © 2000 Koryn Grant. All Rights Reserved.