Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Think C, docs, and OS 9  (Read 1814 times)

thirdbanana

  • 8 MB
  • **
  • Posts: 14
Think C, docs, and OS 9
« on: September 02, 2024, 05:47:22 AM »

A long time ago I used to do some coding in Think C. In fact, one of my lousy programs even ended up in a shareware CD. While I am looking for where my old floppies are -- I found them early last month and thought I would remember where they are, which I did not -- I bumped into the pdf of the Think C book I used ("MacIntosh C Programming Primer: Inside the Toolbox Using Think C (May 1992)"). It seems the examples are for OS 7. So,

  • Is there a doc showing what has changed between OS 7 and 9 as far as programming is concerned? For instance, if I decide to make my code work in OS 7 and M68K/PPC, would it also work in OS9/PPC?
  • Is Think C (I saw version 6 out there) a valid C compiler for OS 9 or should I get code warrior/MPW?
Logged

thirdbanana

  • 8 MB
  • **
  • Posts: 14
Re: Think C, docs, and OS 9
« Reply #1 on: October 16, 2024, 02:51:57 AM »

Also, I downloaded Think C 5.0.2 off macintosh garden, and then tried to build a simple "Hello World" that uses the stdio.h (p46 of "MacIntosh C Programming Primer: Inside the Toolbox Using Think C (May 1992)" does show I need the ANSI library, so I followed its advice ). When I tried to run it, the computer (Mac Mini G4 running OS9) froze up on me. Does that mean Think C 5 does not work well in OS9?
Logged

Bolkonskij

  • Staff Member
  • 256 MB
  • *****
  • Posts: 309
    • Cornica.org
Re: Think C, docs, and OS 9
« Reply #2 on: October 16, 2024, 04:28:33 AM »

Yes, it doesn't! I think it's not even an OS 9 issue, but rather a 68k vs. PPC one. I had run into exactly the same problem when I tried to compile my programs on my Power Mac 8600 running 7.6.1 (instead of the IIci, where I wrote the code).

I think Think C is 68k only (and it can only target 68k too). I love it for it's simplicity yet mindful features and would love to keep using it, but ....

If you want to code on Mac OS 9, I guess you better stick with the de-facto standard of the day, Code-Warrior. (or, if you're masochistic enough - MPW)
Logged

sentient06

  • 8 MB
  • **
  • Posts: 11
Re: Think C, docs, and OS 9
« Reply #3 on: December 04, 2024, 03:14:04 AM »

I've read somewhere that Think C stopped being updated earlier than CodeWarrior and even MPW, so it's indeed pretty unstable after version 5.0.4.

I haven't tried it, but Symantec C++ 8.6 seems to work well on Mac OS 9.2. It doesn't seem to support namespaces though.

Is there a doc showing what has changed between OS 7 and 9 as far as programming is concerned? For instance, if I decide to make my code work in OS 7 and M68K/PPC, would it also work in OS9/PPC?

I was reading a book called "PowerPC Programmer's Toolkit" by Tom Thompson (1996), which I mentioned on another thread. It's a bit of a messy book when it comes to implementing his examples, as the codes are huge, but he does explain the differences between 68k instructions and PowerPC instructions very well. It gets a bit technical, but even if you just read through it missing a few bits and bobs, it's very damn interesting.

If you compile a 68K app on System 7, it should work just fine on any subsequent system. The PowerPC OSes have an emulation layer to execute all 68K system calls. Actually, the Macintosh Toolbox from System 1 could be used for an app completely compatible with all Macintosh systems up to 9.2.2 because the old routines were never dropped. 68000 instructions should work natively on other 68k processors (whereas the opposite isn't true, e.g. 68030-specific instructions won't run on 68020 or 68000.)

Of course, using an old Toolbox has its limitations. System 7 is quite a popular convergence point in a sense, as it's the point where a lot of interesting system updates made into the Mac.

Just make sure you yield processor time back to the system and read the most recent editions of Inside Macintosh for reference. If you have an IDE that lets you check the routine prototypes, they might contain some comments saying what kind of system can run it.

For example, this is the prototype for CustomGetFile:

Code: [Select]
/*
 *  CustomGetFile()
 * 
 *  Availability:
 *    Non-Carbon CFM:   in InterfaceLib 7.1 and later
 *    CarbonLib:        not available
 *    Mac OS X:         not available
 */
EXTERN_API( void )
CustomGetFile( ... ) // etc

And at the top of the file (this example is for StandardFile.h) I can see this:

Code: [Select]
/*
     File:       StandardFile.h
 
     Contains:   Standard File package Interfaces.
 
     Version:    Technology: System 7.5
                 Release:    Universal Interfaces 3.4
 
     Copyright:  � 1990-2001 by Apple Computer, Inc., all rights reserved
 
     Bugs?:      For bug reports, consult the following page on
                 the World Wide Web:
 
                     http://developer.apple.com/bugreporter/
 
*/

I can make some educated guessing by reading that stuff. This was developed for system 7.5 and the CustomGetFile I want to use is for System 7.1. The file has been last udpated in 2001, so it was during the Mac OS 9 era, which suggests it was not updated any further. Any code using that routine should work fine on 7.1 to 9.2.2.

The Inside Macintosh book on Files describes the manager:

Quote
"The Standard File Package still recognizes all procedures available before system software version 7.0 (SFGetFile, SFPutFile, SFPGetFile, and SFPPutFile)"

Then below, it says:

Quote
"If you need to use the procedures available before system software version 7.0, you need to be aware of a number of differences between those procedures and the enhanced procedures."

And then it describes the differences in parameters, returned types and many other things.

It's all about investigation, really. So, I suggest you equip yourself with a bunch of books like these and keep poking about on the header files for comments in the code. If your compiler works fine on your system of choice, and you like it, go for it. But if it crashes on you too often or doesn't support the features you want, try other compilers.

As for myself, I've been using macOS 15 to browse the docs. I enjoy the modern macOS's capacity of parsing text in images, so even when a book is scanned into a PDF full of images, it can find text there. I think it's handy.
« Last Edit: December 04, 2024, 03:39:36 AM by sentient06 »
Logged

Jubadub

  • 256 MB
  • *****
  • Posts: 459
  • There is no Mac in OS X
Re: Think C, docs, and OS 9
« Reply #4 on: December 05, 2024, 11:48:24 AM »

I haven't tried it, but Symantec C++ 8.6 seems to work well on Mac OS 9.2.

Yes, it works completely all the way up to Mac OS 9.2.2, as per discussion here, with the only known exception being the menu item "Project -> Options...", which might possibly require Mac OS 9.0.4 and earlier.

Incidentally, I see absolutely no reason nor benefit in using THINK C, be it before, after, or version 5.0.4 itself, instead of using the latest one, 8.6 (then renamed "Symantec C++"). If there is any concrete, real counterexample, please let me know.
Logged

laulandn

  • 8 MB
  • **
  • Posts: 15
  • Mew Nember
Re: Think C, docs, and OS 9
« Reply #5 on: January 19, 2025, 05:03:32 PM »

If you're targeting PowerPC, and using Symantec, you must use version 8 or higher.  If you're ok running M68k code in emulation, anything goes.

The problem was Symantec was late for the boat to PowerPC.  When 8 finally did come out, it was buggy, had far larger requirements, and was a shocking contrast to the slim, fast, tiny compilers they'd been known for.

Review in MacWorld:
https://archive.org/details/eu_Macworld-1995-07-INT_OCR/page/n65/mode/1up

After that they spent a lot of time catching up, but never hit the peaks of greatness they had with their prior products.  They were much more focused on Java and Windows, maybe.  They never bothered to support Carbon, from what I can tell,.

I wouldn't, personally, recommend them for PowerPC, doubly so for MacOS 9, for some issues people have had, and support for OS and C++ language features lagged CodeWarrior, and even MPW, quite a bit.  Not that it's bad at all, but you'll probably have a much better time without fighting the compiler itself.  For MacOS 9, CodeWarrior is hard to beat.  MPW is extremely powerful, but not user friendly or a traditional IDE, in any sense.

----

With that said, completely different story for M68k development.  Symantec C++ 7 and earlier Think C's are amazingly fast and tiny, and ideal for System 7.5.  If you're doing System 6 development, and don't need C++, Think C 5 will run on a Plus.  If you compare them with Symantec C++ 8.x, it's like night and day.  But that's not what we were talking about...

----

The original question was about moving older projects to newer systems. As far as the MacOS API goes, it's a thin line between the "core" ToolBox and Extensions that got added on, and became standard parts of the OS.

You can add things to 7.0/7.1 that were standard in 7.5/7.6. Same with 7.5/7.6 to "catch up" to 8.0/8.1.   The leap from 8.0/8.1 to PPC only 8.5/8.6/9.x was larger, with many new ToolBox UI calls.  There wasn't as big a jump between 8.5/8.6 and 9.x, especially from a programming standpoint.

Programming for them is similar, in leaps and what is included.  If you require Appearance, for example, you don't necessarily require 8 or higher, as your users can add the Extension to earlier systems.  Same with OpenTransport, and many more things.  You can even use early versions of Carbon on 8.1.

The core API didn't change radically over the years, and so System 7 knowledge still works well on MacOS 9, to a point.  Going from M68k to PowerPC will require some dealing with the Mixed Mode Manager, and Universal Proc Pointers for callbacks.  So that is probably the biggest leap for very old code.
Logged
Pages: [1]   Go Up

Recent Topics