Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!utah-cs!utah-gr!thomas From: thomas@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: net.lang.c Subject: Re: Casting Question Message-ID: <1655@utah-gr.UUCP> Date: Fri, 17-Jan-86 18:09:50 EST Article-I.D.: utah-gr.1655 Posted: Fri Jan 17 18:09:50 1986 Date-Received: Sun, 19-Jan-86 05:00:17 EST References: <162@butler.UUCP> Reply-To: thomas@utah-gr.UUCP (Spencer W. Thomas) Organization: Univ of Utah CS Dept Lines: 22 In article <162@butler.UUCP> chinn@butler.UUCP (David Chinn) writes: >Inst *pc; /* program counter during execution */ > /* pc is declared to be a pointer to an Inst; > . or, a pointer to a pointer to a function */ > pc = *((Inst **)(savepc+2)); /* next stmt */ > ^^^^^^^^^^^^^^^^^^^^^^ > So what is this for? What appears to be happening here is that the location savepc+2 is a POINTER to a location containing the desired pc value. Certainly (in this case) removing the cast will not affect the code (you are still dereferencing savepc+2, and the value there is still a pointer), but the types on the left and right of the assignment DO NOT MATCH! If you run lint over the code, it will complain. The right hand side of the assignment will be an Inst, while the left side is an Inst *. The cast keeps the types right. -- =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA) "Ask not what your kernel can do for you, but rather what you can do for you kernel!"