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 1305 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: 296
    • 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

  • 4 MB
  • **
  • Posts: 7
Re: Think C, docs, and OS 9
« Reply #3 on: Today at 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: Today at 03:39:36 AM by sentient06 »
Logged
Pages: [1]   Go Up

Recent Topics