我很好奇在Mac OS System 7到OS 9上有多少依赖标准Unix功能的C特性能够使用。我没有在该平台上进行过开发,但我知道它没有命令行,也没有标准流可以工作。没有命令行,那么是否有命令行参数?环境变量呢?
我尝试寻找经典的Mac OS编程指南,但是它们非常难找。
我很好奇在Mac OS System 7到OS 9上有多少依赖标准Unix功能的C特性能够使用。我没有在该平台上进行过开发,但我知道它没有命令行,也没有标准流可以工作。没有命令行,那么是否有命令行参数?环境变量呢?
我尝试寻找经典的Mac OS编程指南,但是它们非常难找。
首先,C语言没有任何与Unix有关的特性。C语言可以在Windows上和8位微控制器上顺利运行。
至于经典的Mac OS,有两个主要的编程环境:Metrowerks CodeWarrior和苹果的MPW。
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.
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'
THINK C/Symantec C也有一个标准的I/O窗口,使得移植命令行程序相对容易。通过对话框输入程序参数。
但是,最好的方法是使用MPW - Macintosh程序员工作坊。这是MacOS的一个非常好的命令行环境,拥有优秀的编辑器、可编写脚本、各种“工具”以及许多有用的GUI方面(因此它真正像Mac一样)。
多年来,这可以从苹果的开发者网站免费下载。看起来链接现在可能已经消失了,但我相信可以在网上找到副本,只需稍微搜索即可。(尝试搜索MPW-GM.img.bin或mpw-gm_images。)