home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22190 < prev    next >
Encoding:
Text File  |  1993-01-26  |  2.2 KB  |  51 lines

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