Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!icdoc!qmw-cs!morten From: morten@cs.qmw.ac.uk (Morten Ronseth) Newsgroups: comp.sys.mac.programmer Subject: Re: More on MPW C 3.0 question Message-ID: <1629@sequent.cs.qmw.ac.uk> Date: 20 Feb 90 13:54:13 GMT References: <162.25dfe4b3@waikato.ac.nz> <10311@hoptoad.uucp> Reply-To: morten@cs.qmc.ac.uk (Morten Ronseth) Organization: Computer Science Dept, Queen Mary and Westfield College, U of London, UK. Lines: 92 References: <162.25dfe4b3@waikato.ac.nz> In article <10311@hoptoad.uucp> you write: >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. Agree. Why re-invent the wheel? > >> 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; >> Please, give me a break. Why can't you have pointers to arrays in C? I mean, how do you explain `char *argv[]' and `char **argv'? Surely, you must be familiar with this. >>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. When using your declarations of temps & tempp, the assignement `tempp = temps' will, on any smart compiler (read: gcc), generate a warning: assignement between incompatible pointer types. I assume you mean `*tempp = temps'. I must admit, I'm no big fan of Apple's MPW C 3.0 compiler, and I guess this is yet another example of its inadequacy. When I compiled the `erronous' code (the part with the "address-of" assignement) using gcc (even did -Wall) all the compiler complained about was me not declaring a return type for main and that it had reached the end of a non-void function. I think the problem is the MPW compiler. (ever tried to compile gcc using MPW C 3.0? DON'T! it's a nightmare: I was *this* close to finish it when the MPW compiler suddenly fell over and told me it couldn't allocate anymore registers...(Apple are aware of this bug and it should be fixed in the next version...) also it would only allow strings of lengths up to 509 (or so) chars. Even though this is the ANSI standard, there should be a flag for allowing longer strings. And, the preprocessor is too weak: only 11 levels of #include nesting (gcc has 77 I think) and unable to process some of the #define's in gcc (can't remember which files this happened in): some were to complex... Anybody from Apple reading this?) Oh, by the way; I'm pretty sure that the definition of StringPtr goes smth. like: `typedef Str255 *StringPtr'. Looks familiar? :-) (Haven't looked it up though...) >Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com > >This message does represent the views of Eclectic Software. This message does *not* represent the views of QMW. (Just a disclaimer in case I'm totally wrong; doan think so, tho'...) -- ============================================================================== Morten Lerskau Ronseth UUCP: morten@qmw-cs.uucp or ...seismo!mcvax!ukc!qmw-cs!morten JANET: morten@uk.ac.qmw.cs Post: Dept of Computer Science ARPA: morten%qmw.cs@ucl-cs.arpa Queen Mary and Westfield College Easylink: 19019285 University of London Telex: 893750 QMCUOL Mile End Road Fax: +44 1 981 7517 London E1 4NS Phone: +44 1 975 5220 England