Path: utzoo!utgpu!water!watmath!clyde!att!ihlpl!knudsen From: knudsen@ihlpl.ATT.COM (Knudsen) Newsgroups: comp.lang.c Subject: Re: Broken compilers (Was Portability of passing/operating on structures) Summary: sructure assignment; big endian Message-ID: <7356@ihlpl.ATT.COM> Date: 24 Oct 88 18:46:15 GMT References: <8810111934.AA21941@ucbarpa.Berkeley.EDU> <8308@alice.UUCP> <73946@sun.uucp> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 26 In article <73946@sun.uucp>, jamesa%betelgeuse@Sun.COM (James D. Allen) 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. > [more code example] > (I think this arose because a little-Endian compiler was ported to a > big-Endian machine without ample thought and/or testing.) 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. No problem once you realize it -- after all, C is structured assembler, eh? Actually I like the semantics that casting any pointer to (char *) means "keep the numerical address value the same." -- Mike Knudsen Bell Labs(AT&T) att!ihlpl!knudsen "Lawyers are like handguns and nuclear bombs. Nobody likes them, but the other guy's got one, so I better get one too."