Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Broken compilers (Was Portability of passing/operating on structures) Message-ID: <1988Oct25.164924.7111@utzoo.uucp> Organization: U of Toronto Zoology References: <8810111934.AA21941@ucbarpa.Berkeley.EDU> <8308@alice.UUCP> <73946@sun.uucp> <7356@ihlpl.ATT.COM> Date: Tue, 25 Oct 88 16:49:24 GMT In article <7356@ihlpl.ATT.COM> knudsen@ihlpl.ATT.COM (Knudsen) writes: >> struct { >> whatever; >> } st; >> /* the next will be treated as though it were "foo(&st);" */ >> foo(st); >This is my main objection to structure and array assignment and >passing. Aside from being hideously wasteful of time and stack space, >they permit common typo errors (omission of &) to go undetected. Complain to your compiler vendor(s). The compilers that *I* work with won't let you get away with this, and ANSI C won't either. >Big-Endian (walkie-talkie company) micros also pose an interesting >problem in casting an (int *) to a (char *); to do this right >the compiler should add 1, but does not... Nonsense. What does it *mean* to do that cast? You're assuming that it should get you the low-order char. If you think of C as "structured assembler", this might be plausible; if you think of it as a high-level language -- which it is -- then there is no justification for this. -- The dream *IS* alive... | Henry Spencer at U of Toronto Zoology but not at NASA. |uunet!attcan!utzoo!henry henry@zoo.toronto.edu