Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: More on MPW C 3.0 question Message-ID: <10311@hoptoad.uucp> Date: 19 Feb 90 07:48:46 GMT References: <162.25dfe4b3@waikato.ac.nz> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 52 In article <162.25dfe4b3@waikato.ac.nz> ccc_ldo@waikato.ac.nz writes: >While porting a large C program between versions of MPW C, I came >across a strange quirk in the 3.0 compiler, which is summed up in >the following program: > > typedef unsigned char Str255[256]; Uh, why not use MPW's own definition of Str255? It's identical to the above in effect, so I'm just curious. > main() > { > Str255 > temps, *tempp; "Str255 *tempp" makes no sense. You can't have a pointer to an array in C. The compiler should choke on this, but it doesn't. Instead, your declarations should go: Str255 temps; StringPtr tempp; > tempp = &temps; > >When I try to compile this, the compiler throws up the following >error message: > > # tempp = &temps; > # ? > ### Error 225 Incompatible types for assignment Yep. It's trrying to assign to a nonsensical type, so it's not too surprising that it barfs. However, if you declare as above and say: tempp = temps; everything should be hunky dory. I've noticed that MPW allows these nonsensical types myself; at one point, I think in GetPattern or GetIndPattern, a parameter is defined as a "Pattern *", which makes no sense since Pattern is just an array of eight characters. Nor will it let you generate an lvalue of this nonsensical type by putting the address operator (&) in front of the name of a variable of type Pattern. The only thing you can do to make it work is a type cast to (Pattern *). Sounds pretty much the same as your problem. I think the compiler should disallow these silly declarations in the first place, but if not, it should let you generate pointers to arrays with the address operator. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com This message does represent the views of Eclectic Software.