Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: Amiga programmer's hint $14 Message-ID: <8803032106.AA06910@cory.Berkeley.EDU> Date: 3 Mar 88 21:06:10 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 28 >generate code. For instance, > int foo; > float bar; > bar = (float) foo; >should generate code to convert foo to a float. Furthermore, the result of >a cast is an rvalue. That is why you can't always use casts on the left >side of an assignment. Now, some compilers, like the BSD vax compiler On the left side of an assignment? Yow! That isn't C. Still, if you want to cheat you can get around the automatic type conversion: int foo; float bar; bar = *(float *)&foo; /*sizeof(float) had better equal sizeof(int)*/ /*for this to work */ Believe it or not, I have seen people do this! Actually, this sort of thing is useful in certain cases. But I digress. As far as C goes, this is the deal with casts: (anycast)variable = variable; NOT LEGAL variable = &(anycast)variable; NOT LEGAL variable = (somecasts)&variable; LEGAL char c = *(char *)&bar; LEGAL. (USEFUL?) -Matt