gaines@mars.njit.edu (Starman) (02/16/91)
Other than what little documentation the CD Rom has, I can't seem to figure this out: I'm re-writing my graphics program for System 7 goodies. First off, why doesn't the compiler like <stdio.h>? For some reason it says "#define NULL 0L already defined". Then, when I try to compile my module with SFPut, it says that the call doesn't match the prototype. Ick! This makes no sense at all to me. Any help, people? =========================================================================== "They can fly rings around the moon, | Mike but we're years ahead of them on the highway" | gaines@mars.njit.edu System 7 on an 800k floppy? HA! ===========================================================================
chaffee@reed.UUCP (Alex Chaffee) (02/19/91)
In <2322@njitgw.njit.edu> gaines@mars.njit.edu (Starman) writes: >Other than what little documentation the CD Rom has, I can't seem to >figure this out: I'm re-writing my graphics program for System 7 >goodies. First off, why doesn't the compiler like <stdio.h>? For some >reason it says "#define NULL 0L already defined". Then, when I try to >compile my module with SFPut, it says that the call doesn't match the >prototype. Ick! This makes no sense at all to me. Any help, people? I haven't looked into the first problem, but the second seems to be an actual bug/typo in the new Think C headers. I got around it by going into StdFile.h, finding the prototypes section at the end of the file, and changing all references to "SFTypeList *" to "SFTypeList". (Then recompiling MacHeaders). The SF routines expect a SFTypeList (an array, therefore a pointer), but the prototype expects an SFTypeList * (a pointer to an array, therefore a **). Can any Symantec lurkers throw some light on this? - Alex -- Alex Chaffee chaffee@reed.{UUCP,BITNET} Reed College, Portland OR 97202 ____________________
chaffee@reed.UUCP (Alex Chaffee) (02/26/91)
Gad! Not *this* topic again :-)!
Not "again," "still." :)
To restate K&R, arrays become pointers to their first elements when
used as parameters in a function call.
Understood.
The decision to use the address of the typelist is based on the C
User Manual, which states that you should pass the address of any
toolbox argument whose size is greater than 4 bytes. If you use
sizeof(), you'll find that it's 16 bytes. Ergo, pass it by address.
Aha! So that's the rationale. It makes sense now. However, it was a shock to
find that *your* code - the Think Class Library code, specifically
CApplication.c - broke. Thus you released improper code -- naughty,
naughty! ;) (By the way, I still prefer passing my arrays as pointers, so
I'll keep my change to the .h file.)
Re: System 7.0, you may find many problems with the new headers.
Many files have changed, and more functions are prototyped that
weren't before. Problems with prototypes shouldn't be too hard to
fix, though.
-phil
--
Phil Shapiro Technical Support Analyst
Language Products Group Symantec Corporation
Internet: phils@chaos.cs.brandeis.edu
With nothing better to do than pick semantic nits late at night, I remain,
- Alex
--
Alex Chaffee
chaffee@reed.{UUCP,BITNET}
Reed College, Portland OR 97202
____________________