Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!agate!violet.berkeley.edu!edmoy From: edmoy@violet.berkeley.edu Newsgroups: comp.sys.mac.programmer Subject: Re: strings again Message-ID: <7354@agate.BERKELEY.EDU> Date: 3 Mar 88 19:17:24 GMT References: <4629@pucc.Princeton.EDU> Sender: usenet@agate.BERKELEY.EDU Reply-To: edmoy@violet.berkeley.edu.UUCP () Organization: University of California, Berkeley Lines: 35 In article <4629@pucc.Princeton.EDU> MJSCHMEL@pucc.Princeton.EDU writes: > . . . > DebugStr(buffer); /* type mismatch here */ > > printf("%s\nDone.\n",str); /* it's okay, it's an MPW tool */ >} > >Gave me a "Type mismatch." Why did it do that, I wondered. >Then I saw that I had prototyped it that way! (Which shouldn't >be faulted, because I got it verbatim from the MPW manual.) > . . . > >Is there any way I could have made it work with the original >prototype? Simple typecasting - > DebugStr ((Str255) buffer); >- did not work. (Why not?) I use LSC, but the problem is similar. Pascal strings are (after hunting down the type casting) unsigned chars. So the following should work: DebugStr ((unsigned char *) buffer); This is typedef'ed to StringPtr in some places so DebugStr ((StringPtr) buffer); Str255 typedef is an array of unsigned chars, and you can't typedef with arrays, only pointers in this case. Edward Moy Workstation Software Support Group University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy