Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS 7-9 - C programming

I'm curious how many C features that depend on standard Unix features work on Mac OS System 7 through OS 9. I don't have any development experience with the platform, but I know that there is no command line nor anywhere for the standard streams to work. Without a command line are there any command-line arguments? What about environment variables?

I did try looking for a classic Mac OS programming guide, but they're surprisingly hard to find.

like image 406
Dai Avatar asked Nov 19 '12 22:11

Dai


People also ask

Can you program in C on Mac?

To run the C program in MacOS we need a code editor and code compiler. The Code editor is used to write source code while the code compiler converts the source code into executable files. To write the source code Microsoft Visual Studio Code is used while to convert it into executable files we use command-line tools.

Can I use Visual Studio for C on Mac?

Visual Studio 2022 for Mac includes nearly everything you'll need for .NET 7 development, from responsive C# web UIs in Blazor to event-driven solutions using Azure Functions.

Is C++ used in MacOS?

C++ plays an important part in well-known operating systems, from MacOS and Windows to mobile operating systems like iOS. In general, operating systems need to be fast and efficient at managing system resources.


1 Answers

First of all, there are no C features that are dependent on Unix. C runs just fine on Windows, and it runs just fine on 8-bit microcontrollers.

As for classic Mac OS, there were two primary programming environments: Metrowerks CodeWarrior and Apple's MPW.

  1. CodeWarrior came with a library called SIOUX which opened up a window and provided simple I/O. Any printf statements would print to this window. There's no piping or sockets, but that's not part of the C standard anyway (pipes are a part of POSIX). Using SIOUX, you could port a simple program to Mac OS as long as it stuck to portable C.

  2. Apple's MPW was the other option. MPW provided a command line, a bunch of command-line programs (compilers for C, C++, Pascal, assembly), and dialog box "shells" for generating command line arguments to the programs. You could even use pipes, set environment variables, et cetera.

    There were, however, some major differences in functionality between Unix and MPW. MPW had a great interface, but you could not run two command line programs simultaneously, not even in the very trivial case where one is suspended to run the other. This meant that the "make" program couldn't run the compiler. Instead, "make" generated a shell script which would run the compiler. You'd typically have some kind of keyboard shortcut that would run "make" and then run the resulting output as a shell script.

    Now, this seems to imply that pipes wouldn't work, but I think pipes were just syntactic sugar for working with temporary files.

    Xcode has no MPW heritage, as far as I know. Xcode derives from Project Builder which was developed at NeXT, and NeXT was always Unix. Apple ported some of the old MPW command-line tools to OS X, but not many. The big one is Rez (and DeRez). Since they're shipped with the latest Xcode, I guess somebody is probably still using them. The Rez headers are still around, to get a blast from the past check out:

    find /System/Library/Frameworks -name '*.r'
    

It seems like Apple has really scrubbed their development website of anything older than 10.6, which is a bit of a shame. Not too long ago you could still find the old pre-Carbon documentation, including all of the "Inside Macintosh" series on Apple's website. You also used to be able to get MPW from Apple's FTP site (it was free), and I still have the downloads, but I don't know if you can still download it.

Mind you, you'll need 10.4 (or earlier) and a PowerPC computer before you can even consider playing around with this, unless you've somehow managed to get Sheep Shaver working.

Funny tidbit, there were some funny error messages that MPW's C compiler could produce.

a typedef name was a complete surprise to me at this point in your program

You can't modify a constant, float upstream, win an argument with the IRS, or satisfy this compiler

...And the lord said, 'lo, there shall only be case or default labels inside a switch statement'

type in (cast) must be scalar; ANSI 3.3.4; page 39, lines 10-11 (I know you don't care, I'm just trying to annoy you)

Call me paranoid but finding '/*' inside this comment makes me suspicious

Symbol table full - fatal heap error; please go buy a RAM upgrade from your local Apple dealer

Too many errors on one line (make fewer)

This label is the target of a goto from outside of the block containing this label AND this block has an automatic variable with an initializer AND your window wasn't wide enough to read this whole error message

we already did this function
like image 187
Dietrich Epp Avatar answered Sep 25 '22 15:09

Dietrich Epp