Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site butler.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!hplabs!tektronix!uw-beaver!uw-june!entropy!dataio!butler!chinn From: chinn@butler.UUCP (David Chinn) Newsgroups: net.lang.c Subject: Casting Question Message-ID: <162@butler.UUCP> Date: Tue, 14-Jan-86 00:24:57 EST Article-I.D.: butler.162 Posted: Tue Jan 14 00:24:57 1986 Date-Received: Fri, 17-Jan-86 03:13:57 EST Organization: Butler - Controls Div., Kirkland WA Lines: 40 *** REPLACE THIS LINE WITH YOUR MESSAGE *** I have been looking at hoc, which appeared on the net some time ago. I am relatively new to the language (C) and so was puzzled by the following .... typedef int (*Inst)(); /* machine instruction */ /* Inst is typedefed to a "pointer to a function returning an integer */ . 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 */ ifcode() { Inst *savepc= pc; /* then part */ /* savepc is the same as pc */ pc = *((Inst **)(savepc+2)); /* next stmt */ ^^^^^^^^^^^^^^^^^^^^^^ So what is this for? } I understand that the cast makes it (savepc+2) a pointer to a pointer to an Inst (or a pointer to a pointer to a pointer to a function returning an integer). But then the de-referencing star on the outside takes one level of indirection away, making savepc+2 what it was anyway ( a pointer to a pointer to a function returning an integer.) I compiled hoc and tested the if statement; it worked. I edited code.c and removed the seemingly extraneous cast and de-ref: it still worked. Any enlightenment would be appreciated.... ... uw-beaver david m chinn !{tikal,teltone} box 2249 !dataio!butler!chinn kirkland, wash 98083