Path: utzoo!attcan!uunet!samsung!usc!apple!agate!ragu.berkeley.edu!lippin From: lippin@ragu.berkeley.edu (The Apathist) Newsgroups: comp.sys.mac.programmer Subject: Re: ThinkC prototypes and Str255 args Message-ID: <1990Sep16.003553.9541@agate.berkeley.edu> Date: 16 Sep 90 00:35:53 GMT References: <1990Sep15.154434.17307@midway.uchicago.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator) Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 29 Recently fri0@quads.uchicago.edu (Christian E. Fritze) wrote: > >I'm using ThinkC's Class libraries with the Check Prototypes option set. > >I'd like to be able to call functions which expect arguments of the tye Str255 >with a string I build on the fly. If I try to pass a string to a function like > >SomeFunction("\pHere's my string"); > >and the compiler expects a Str255 as an argument, I get a compile error saying >that the argument doesn't match the prototype. Str255 is an array of unsigned char, while string literals and probably the string you built on the fly are arrays of signed char. I recommend using a cast to StringPtr for the literals, and using Str255/StringPtr/unsigned char[] for building your own strings. You can avoid the cast entirely by not using string literals -- put them in resources instead. (Well, not entirely -- I do, but I rewrote the prototypes for GetNamedResource and Get1NamedResource to take char *.) The bright side to this is that pointers to pascal strings and C strings can't be confused; you have to use an explicit cast to get the signedness right. --Tom Lippincott lippin@math.berkeley.edu "A repo man's life is always intense." --"Repo Man"