Broken compilers (Was Portability of passing/operating on structures)

Henry Spencer henry at utzoo.uucp
Wed Oct 26 02:49:24 AEST 1988


In article <7356 at ihlpl.ATT.COM> knudsen at 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 at zoo.toronto.edu



More information about the Comp.lang.c mailing list