Posted 2025-04-13 | Back to blog index
In the process of porting my MPW C program to CodeWarrior; I'm now past the easy part of "need to fix missing header files and rename old toolbox calls" and into the need-to-read-a-book parts of "C doesn't have a concept of booleans so what does this compiler expect" and how to make pointers to functions work kind of stuff...
Yay, I successfully got it to build under CodeWarrior!
Files seem to work fine but it doesn't like the HTTP parsing code - loading a URL results in this error (that it can't find the end of the HTTP headers)
An excuse to try out the CodeWarrior debugger! This thing looks awesome!
From this I can see that the problem seems to be that the request isn't being built/sent properly and the server is sending a 400 Bad Request error, which is why it can't find a result and fails.
And it's fixed!
The problem was due to MPW having a backwards interpretation of \n and \r that I was using, and CodeWarrior uses the standard one! They even have an option in the compiler settings to use the MPW mode.
I did a quick web search to see if anyone had discussed the history of this MPW feature, but instead found a Stack Overflow thread with everyone confidently incorrecting each other that it's impossible and never happened, so those are the "facts" your LLMs are going to be trained on.
If anyone is curious to see the changes required: https://github.com/kalleboo/AIRConfig/commit/ba921ee84efb666de5f5599cb9fda966dc2044f6
In the end this is what I had to do:
- Remove all the Mac Toolbox header includes, CodeWarrior does it automagically
- Remove the jank “include all C files directly in the main file" method I used to avoid having to learn MPW Make. CW projects are automatic
- Add missing function prototypes (that MPW didn't need) and externs that I now need when it's not all one postprocessed file
- Fix that \r and \n are reversed in MPW
- Rename old "short" Toolbox calls to newer "long" ones… (1/2)
- Add missing define for geneva font family ID
- Remove MPW-specific boilerplate (_DataInit, QDGlobals)
- Ditch Rez file in favor of a ResEdit file
The Boolean and function pointer stuff I thought I had problems with in the first post were red herrings to other problems with my function prototypes/externs and how I was putting them in header files. Both Booleans and function pointers work exactly the same as in MPW!
(2/2)
I need to start tracking these changes in Projector/SourceServer instead of git 🤔
I've never even tried Projector before, checking the web I'm not finding any information on how it works, does it just work with regular volumes and lock files? It doesn't sound like it has any kind of central server.
I am now controlling my versions like it's 1997!
I'm using the CWProjector plugin for CodeWarrior to connect to MPW SourceServer, working against a Projector project on an AppleShare share, so I can work from either my PowerMac G4 or my PowerBook G3 depending on where I want to work!
For files that are not checked out, SourceServer adds a "ckid" resource that software can look at to check if they should allow you to edit the file or not - CodeWarrior offers to automatically check it out for you, and even ResEdit is smart enough to show a warning! I've definitely never seen that ResEdit dialog before!
Here's a video showing the whole workflow!