Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!sage.cc.purdue.edu!ar4 From: ar4@sage.cc.purdue.edu (Piper Keairnes) Newsgroups: comp.sys.mac.programmer Subject: Re: ThinkC prototypes and Str255 args Message-ID: <4464@sage.cc.purdue.edu> Date: 18 Sep 90 15:08:15 GMT Organization: Purdue University Lines: 35 To clear up Str255 matters... Kernighan & Ritchie: "In C, all function arguments are passed 'by value'" For arrays, if only the name of the array is specified as an argument then the value of the address of the array is passed. To quote further, "..there is no copying of array elements." Here is the definition of Str255 and StringPtr for ThinkC v4.0: typedef unsigned char Str255[256]; typedef unsigned char * StringPtr,** StringHandle ; In a previous posting, I described a way of getting around the Str255 prototype problem. The code I gave did not consider that Str255 is simply a unsigned char *. So, in order pass a Str255 string literal, all that must be done is... SomeFunction((StringPtr) "\pSome String"); Explanation... First off, you (and I) might try to typecast with (Str255). This is an illegal typecast. You may notice, however, that a reference to a variable of type Str255 without subscripts is simply an unsigned char *. So, you can typecast the string as a (StringPtr) which is of type unsigned char *. Now, the compiler sees that two unsigned char *'s match up and it will go on without a problem. This is all just some of the fun we have when mixing C and Pascal definitions.... Sorry if my earlier post confused/upset anyone. _____ Piper Keairnes - Computer Science ** Purdue University Computing Center ** INTERNET: ar4@sage.cc.purdue.edu ** Unisys Corporation Co-op Student ** BITNET: xar4@purccvm.bitnet ** Macintosh Programmer/ Specialist **