home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!spool.mu.edu!yale.edu!yale!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: Re: &StringPtr -vs- StringPtr?
- Message-ID: <1993Jan26.063928.7980@hobbes.kzoo.edu>
- Organization: Kalamazoo College
- References: <1993Jan22.200837.13294@kronos.arc.nasa.gov> <1993Jan22.220940.21096@hobbes.kzoo.edu> <1993Jan25.211652.28191@kronos.arc.nasa.gov>
- Date: Tue, 26 Jan 1993 06:39:28 GMT
- Lines: 40
-
- joshr@kronos.arc.nasa.gov (Joshua Rabinowitz-Summer-91) writes:
- >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
- >>josh writes:
- >>>I would say that if you passed msg1 (not &msg1), it SHOULD accept it.
- >>>I believe I usually must cast in that situation as well, though.
- >>
- >>I don't think so. At least, I don't have to, and I keep ThC on its
- >>strictest type-checking.
- >
- >Hmmm. Did you recompile MacHeaders with the strcit prototype #define
- >chosen? I think the (ConstStr255Param) need only cropped up after
- >I made that change.
-
- Yep, SIMPLIFY_PROTOTYPES is 0.
-
- K&R sez: "Except that it should diagnose explicit attempts to change
- 'const' objects, a compiler may ignore [the const keyword]." (p. 211)
- I don't see any special notes about const in ch. 22 of the ThC user's
- manual.
-
- Passing an (unsigned char*) to a function that expects a (const unsigned
- char*) should be perfectly legal. The "const" only hints that the
- function won't change the value of the pointer, not that the pointer has
- to be special in any way. Perhaps you had the "pascal strings are of
- type (unsigned char*)" box unchecked, so that your strings were (char*)?
- That'd trip an error, and casting would fix it, but you could have
- casted to (StringPtr) as well as (ConstStr255Param).
-
- Boy, you learn all kinds of interesting things going through the header
- files. Get this, the Types.h macro "Length(s)" returns the length byte
- of the string s. I never knew that was there...
-
- >Interesting, that bit about sizeof(msg).
- >What happens at sizeof(&msg) ( ;-) )?
-
- I'd expect you'd get the size of the pointer: 4.
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "The woman hung out a sign that said 'baby welcome' when she had sex."
- - krueger@galileo.physics.arizona.edu (Ted Krueger)
-